Link to home
Start Free TrialLog in
Avatar of kollk
kollk

asked on

How to create an ISAPI module in Visual Basic

As said, how do you create an ISAPI module for IIS in Visual Basic?
I understand it can be done through OLEISAPI, somehow.
Something good with that should do it.

As a side-question, i guess (almost sure) TRUE isapi can be built from VB, with the aid of Udi Shitrit's TRUE Dll compiler for VB. This little thing is free, and allows us to export functions from VB as any true DLL would.

My guess is that, provided one of the experts here translate the PEXTENSION_CONTROL_BLOCK block from C to VB, we must be capable of creating anything we want as TRUE ISAPI. I will double the points if anyone gives the translation.

Well, thats it. Thanks for everyone in advance.
Avatar of Hermetic
Hermetic

quote from a book: "Active Visual Basic"

"....Writing ISAPI extensions is only possible in C/C++ because it requires you to export functions directly from the DLL, a feature not available in Visual Basic.  Visual Basic is, of course, capable of creating DLLs, but the DLLs produced by Visual Basic are in-process COM servers and cannot directly export functions.  To bridge this gap, Microsoft created an ISAPI extension called OLEISAPI, which can call in-process COM servers, enabling Visual Basic programmers to create ISAPI extensions with OLEISAPI as the go-between. OLEISAPI came with some early beta versions of the ActiveX SDK, but then it disappeared. It has been replaced by Active Server Pages,...."

If you are stuck on VB and don't want to learn C++.
My suggestion to you would be to write your extension as a COM object in VB and then write (or have someone write) a C++ wrapper that is the ISAPI extension.  This wrapper would basically just forward calls to your VB COM object.
Avatar of Mohammed Nasman
Hello

  VB can't create native ISAPI, but with some tools like Tornado you can do that, look at
http://www.sgani.com/tornado001.asp

for using vb with help of OLEISAPI look at

http://archive.baarns.com/DevOnly/Notes/VBIT1096.asp

http://www.emu.edu.tr/english/facilitiesservices/computercenter/bookslib/Web%20Database%20Developer's%20Guide%20with%20Visual%20Basic%205/htm/ch22.htm

http://docs.rinet.ru:8083/MIIS/ch6.htm

I haven't created ISAPI with VB before, but I used Delphi to do that, and create ISAPI application using Delphi is very simple and easy, with the powerful that you can find in VC++

Best regards
ASKER CERTIFIED SOLUTION
Avatar of Shaka913
Shaka913

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
hearing...
Avatar of kollk

ASKER

Can anyone translate this into a Visual Basic type?
Or point to a page where i can found the correct translation for each variable, ie. C DWORD = VB Long, or something like that. I'm very interested in Shaka913's comment, but still i'd prefer the other approach.
Remember i will double the points if i can do it.


Anyway, what i'd love to see in VB format is this:

typedef struct _EXTENSION_CONTROL_BLOCK
{
   DWORD     cbSize;                 // size of this struct.
   DWORD     dwVersion;              // version info of this spec
   HCONN     ConnID;                 // Context number not to be modified!
   DWORD     dwHttpStatusCode;       // HTTP Status code
   CHAR      lpszLogData[HSE_LOG_BUFFER_LEN];// null terminated log info

   LPSTR     lpszMethod;             // REQUEST_METHOD
   LPSTR     lpszQueryString;        // QUERY_STRING
   LPSTR     lpszPathInfo;           // PATH_INFO
   LPSTR     lpszPathTranslated;     // PATH_TRANSLATED

   DWORD     cbTotalBytes;           // Total bytes indicated from client
   DWORD     cbAvailable;            // Available number of bytes
   LPBYTE    lpbData;                // pointer to cbAvailable bytes

   LPSTR     lpszContentType;        // Content type of client data

   BOOL (WINAPI * GetServerVariable) (HCONN hConn,
   LPSTR      lpszVariableName,
   LPVOID     lpvBuffer,
   LPDWORD    lpdwSize );

   BOOL (WINAPI * WriteClient)  (HCONN ConnID,
   LPVOID     Buffer,
   LPDWORD    lpdwBytes,
   DWORD      dwReserved );

   BOOL (WINAPI * ReadClient)  (HCONN ConnID,
   LPVOID     lpvBuffer,
   LPDWORD    lpdwSize );

   BOOL (WINAPI * ServerSupportFunction)( HCONN hConn,
   DWORD      dwHSERequest,
   LPVOID     lpvBuffer,
   LPDWORD    lpdwSize,
   LPDWORD    lpdwDataType );

}EXTENSION_CONTROL_BLOCK, *LPEXTENSION_CONTROL_BLOCK;
Avatar of kollk

ASKER

Can anyone translate this into a Visual Basic type?
Or point to a page where i can found the correct translation for each variable, ie. C DWORD = VB Long, or something like that. I'm very interested in Shaka913's comment, but still i'd prefer the other approach.
Remember i will double the points if i can do it.


Anyway, what i'd love to see in VB format is this:

typedef struct _EXTENSION_CONTROL_BLOCK
{
   DWORD     cbSize;                 // size of this struct.
   DWORD     dwVersion;              // version info of this spec
   HCONN     ConnID;                 // Context number not to be modified!
   DWORD     dwHttpStatusCode;       // HTTP Status code
   CHAR      lpszLogData[HSE_LOG_BUFFER_LEN];// null terminated log info

   LPSTR     lpszMethod;             // REQUEST_METHOD
   LPSTR     lpszQueryString;        // QUERY_STRING
   LPSTR     lpszPathInfo;           // PATH_INFO
   LPSTR     lpszPathTranslated;     // PATH_TRANSLATED

   DWORD     cbTotalBytes;           // Total bytes indicated from client
   DWORD     cbAvailable;            // Available number of bytes
   LPBYTE    lpbData;                // pointer to cbAvailable bytes

   LPSTR     lpszContentType;        // Content type of client data

   BOOL (WINAPI * GetServerVariable) (HCONN hConn,
   LPSTR      lpszVariableName,
   LPVOID     lpvBuffer,
   LPDWORD    lpdwSize );

   BOOL (WINAPI * WriteClient)  (HCONN ConnID,
   LPVOID     Buffer,
   LPDWORD    lpdwBytes,
   DWORD      dwReserved );

   BOOL (WINAPI * ReadClient)  (HCONN ConnID,
   LPVOID     lpvBuffer,
   LPDWORD    lpdwSize );

   BOOL (WINAPI * ServerSupportFunction)( HCONN hConn,
   DWORD      dwHSERequest,
   LPVOID     lpvBuffer,
   LPDWORD    lpdwSize,
   LPDWORD    lpdwDataType );

}EXTENSION_CONTROL_BLOCK, *LPEXTENSION_CONTROL_BLOCK;

Here is some code to do what you want I suspect, as I said before this is all taken care of for you using the Web Classes structure, it does all of this, but hides it from you... What did below was show you the start of how to translate the complex C structure into VB, the hardest part are the CallBack functions that have to be setup.

Good Luck



Public Type GetServerVariableCBType
    lpszVariableName As String
    lpvBuffer As Long 'this is a buffer that is pointed to by this string
    lpdwSize As Long
End Type

Public Type ExtensionControlBlockType
    cbSize As Double
    dwVersion As Double
    ConnID As Long 'Any pointer or handle is a long
    dwHttpStatusCode As Double
    lpszLogData As String
    lpszMethod As String             '// REQUEST_METHOD
    lpszQueryString As String        '// QUERY_STRING
    lpszPathInfo As String          '// PATH_INFO
    lpszPathTranslated  As String    ' // PATH_TRANSLATED

    GetServerVariableCB As GetServerVariableCBType
   
End Type

Public Function GetServerVariable(VarName As String, Buffer As Long, Size As Long) As Boolean
    'do something with the information...
End Function

Public Function SomeFunction()
    Dim MyECB As ExtensionControlBlockType
    Dim GSVCallBack As GetServerVariableCBType
   
    With MyECB
       .GetServerVariableCB = DoNothing(AddressOf GetServerVariable)
       .cbSize = 12 ' Made up numbers
       .ConnID = 1  ' Made Up Numbers...
    End With

End Function


Private Function DoNothing(ByVal Number As Long) As Long
  DoNothing = Number
End Function