源码 Hello, World!

源码 Hello, World!

来源(null)

下载源文件: i1833_001hello2.rar

hello2.c

/*++
Module Name:
hello2.c
Abstract:
This module is an example of the hello2 World ISAPI Application.
Revision History:
--*/
#include <windows.h>
#include <httpext.h>
//#include "hello2.h"
/*++
Routine Description:
This function DllLibMain() is the main initialization function [ic:ccc]
for
this DLL. It initializes local variables and prepares it to be [ic:ccc]
invoked
subsequently.
Arguments:
hinstDll Instance Handle of the DLL
fdwReason Reason why NT called this DLL
lpvReserved Reserved parameter for future use.
Return Value:
Returns TRUE is successful; otherwise FALSE is returned.
--*/

void WriteString (EXTENSION_CONTROL_BLOCK *pECB, LPCTSTR lpsz);
void HtmlCreatePage (EXTENSION_CONTROL_BLOCK *pECB, LPCTSTR //[ic:ccc]
                     lpszTitle);
void HtmlEndPage (EXTENSION_CONTROL_BLOCK *pECB);

BOOL WINAPI DllMain(IN HINSTANCE hinstDll, IN DWORD fdwReason, //[ic:ccc]
IN LPVOID lpvContext OPTIONAL )
{
    BOOL fReturn = TRUE;
    switch (fdwReason )
    {
        //
        // Initialize various data and modules.
        //
        case DLL_PROCESS_ATTACH:
        break;
        case DLL_PROCESS_DETACH:
        break;
        default:
        break;
    } /* switch */
    return ( fReturn);
} /* DllLibMain() */
/*++
Routine Description:
This is the first function that is called when this ISAPI DLL [ic:ccc]
is loaded.
We should fill in the version information in the structure [ic:ccc]
passed in.
Arguments:
pVer - pointer to Server Extension Version Information [ic:ccc]
structure.
Returns:
TRUE for success and FALSE for failure.
On success the valid version information is stored in *pVer.
--*/
BOOL WINAPI GetExtensionVersion (HSE_VERSION_INFO * pver )
{
    pver->dwExtensionVersion = MAKELONG( HSE_VERSION_MINOR, //[ic:ccc]
    HSE_VERSION_MAJOR );
    strcpy( pver->lpszExtensionDesc,
    "hello2 World ISAPI Server Application." );
    return TRUE;
}
/*++
Routine Description:
This is the main function that is called for this ISAPI [ic:ccc]
Extension.
This function processes the request and sends out appropriate [ic:ccc]
response.
Arguments:
pecb - pointer to EXTENSION_CONTROL_BLOCK, which contains [ic:ccc]
most of the
required variables for the extension called. In [ic:ccc]
addition,
it contains the various callbacks as appropriate.
Returns:
HSE_STATUS code indicating the success/failure of this call.
--*/
DWORD WINAPI HttpExtensionProc( EXTENSION_CONTROL_BLOCK * pecb )
{
    // Create a basic HTML page
    HtmlCreatePage (pecb, TEXT("hello2 World Reply"));
    WriteString (pecb, TEXT("hello2, World!"));
    WriteString (pecb, TEXT("/r/n"));
    HtmlEndPage (pecb);
    return HSE_STATUS_SUCCESS;
}
//
// WriteString writes an ASCII string to the web browser
//
void WriteString (EXTENSION_CONTROL_BLOCK *pECB, LPCTSTR lpsz)
{
    DWORD dwBytesWritten;
    dwBytesWritten = lstrlen (lpsz);
    pECB->WriteClient (pECB->ConnID, (PVOID) lpsz, &dwBytesWritten, //[ic:ccc]
    0);
}
//
// HtmlCreatePage adds <HTML> and a title
//
void HtmlCreatePage (EXTENSION_CONTROL_BLOCK *pECB, LPCTSTR //[ic:ccc]
lpszTitle)
{
    // IIS does this for us
    //WriteString (pECB, TEXT("Content-Type: text/html/r/n"));
    WriteString (pECB, TEXT("<HTML>/r/n/r/n"));
    if (lpszTitle)
    {
        WriteString (pECB, TEXT("<HEAD><TITLE>"));
        WriteString (pECB, lpszTitle);
        WriteString (pECB, TEXT("</TITLE></HEAD>/r/n/r/n"));
    }
    WriteString (pECB, TEXT("<BODY>/r/n/r/n"));
}

void HtmlEndPage (EXTENSION_CONTROL_BLOCK *pECB)
{
    WriteString (pECB, TEXT("</BODY>/r/n/r/n"));
    WriteString (pECB, TEXT("</HTML>/r/n"));
}


hello2.def
; hello2.def : Declares the module parameters for the DLL.

LIBRARY      "hello2"
DESCRIPTION  'hello2 Windows Dynamic Link Library'

EXPORTS
    GetExtensionVersion
    HttpExtensionProc
    ; Explicit exports can go here


hello2.dsp
# Microsoft Developer Studio Project File - Name="hello2" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **

# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102

CFG=hello2 - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE 
!MESSAGE NMAKE /f "hello2.mak".
!MESSAGE 
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE 
!MESSAGE NMAKE /f "hello2.mak" CFG="hello2 - Win32 Debug"
!MESSAGE 
!MESSAGE Possible choices for configuration are:
!MESSAGE 
!MESSAGE "hello2 - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "hello2 - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE 

# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe

!IF  "$(CFG)" == "hello2 - Win32 Release"

# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "hello2_EXPORTS" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "hello2_EXPORTS" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x804 /d "NDEBUG"
# ADD RSC /l 0x804 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"hello2.dll"

!ELSEIF  "$(CFG)" == "hello2 - Win32 Debug"

# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "hello2_EXPORTS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "hello2_EXPORTS" /YX /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x804 /d "_DEBUG"
# ADD RSC /l 0x804 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept

!ENDIF 

# Begin Target

# Name "hello2 - Win32 Release"
# Name "hello2 - Win32 Debug"
# Begin Group "Source Files"

# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File

SOURCE=./hello2.cpp
# End Source File
# End Group
# Begin Group "Header Files"

# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File

SOURCE=./hello2.def
# End Source File
# End Group
# Begin Group "Resource Files"

# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project



执行结果:
Hello, World!


执行结果(HTML):
<HTML>

<HEAD><TITLE>Hello World Reply</TITLE></HEAD>

<BODY>

Hello, World!
</BODY>

</HTML>



 

Link: http://www.asm32.net/article_disp.asp?ID=1833


 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值