?
Solved

How to create an ISAPI module in Visual Basic

Posted on 2003-03-15
7
Medium Priority
?
961 Views
Last Modified: 2013-11-25
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.
0
Comment
Question by:kollk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 1

Expert Comment

by:Hermetic
ID: 8144788
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.
0
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 8144855
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
0
 
LVL 3

Accepted Solution

by:
Shaka913 earned 1000 total points
ID: 8145227
Kollk,
ISAPI is typically used to create streamable content for websites with coded back-ends (in this case VB). VB6 provides a structure to do this, it is called Web Classes, and is a very under-utilized portion of VB. Essentially you use a designer called a Web Class Designer that will create some standard functions for you, then you put your content into those functions on how you want the web pages modified and created. I have written entire web applications in VB this way without ever having to write a line of HTML or ASP.  

To see a web classes started do this: From VB startup, under the NEW tab, choose IIS Application, this will create a bare bones project that adds a webclass designer to your project. From there HELP will guide the way for you.

The create ASP file and DLL are ISAPI, so it is possible to do this from VB

Good Luck
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 8145735
hearing...
0
 

Author Comment

by:kollk
ID: 8146706
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;
0
 

Author Comment

by:kollk
ID: 8146857
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;
0
 
LVL 3

Expert Comment

by:Shaka913
ID: 8146912

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

0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question