Very simple CGI program demonstating how to make a simple web page through code....
Open a new project, remove the default form, add a BAS module, and put this code in the BAS module.
From project properties, make sure the "Startup Object" is Sub Main
Compile the project, and put the exe in the C:\Inetpub\Scripts directory
Right click the exe and give propper permissions to the exe.
Finally, open your browser, and type this: http://localhost/Scripts/MyCGI.exe (that is, if you named your exe MyCGI.exe, otherwise put whatever it's name is)
Declare Function GetStdHandle Lib "kernel32" (ByVal nStdHandle As Long) As Long
Declare Function ReadFile Lib "kernel32" (ByVal hFile As Long, lpBuffer As Any, ByVal nNumberOfBytesToRead As Long, lpNumberOfBytesRead As Long, lpOverlapped As Any) As Long
Declare Function WriteFile Lib "kernel32" (ByVal hFile As Long, ByVal lpBuffer As String, ByVal nNumberOfBytesToWrite As Long, lpNumberOfBytesWritten As Long, lpOverlapped As Any) As Long
Public Const STD_INPUT_HANDLE = -10&
Public Const STD_OUTPUT_HANDLE = -11&
Public Const FILE_BEGIN = 0&
Public hStdIn As Long ' handle of Standard Input
Public hStdOut As Long ' handle of Standard Output
Public Sub Main()
Dim Count As Long, Buff As String
hStdIn = GetStdHandle(STD_INPUT_HANDLE)
hStdOut = GetStdHandle(STD_OUTPUT_HANDLE)
Send "HTTP/1.0 200 OK"
Send "Content-type: text/html" & vbCrLf
Open App.Path & "\TestFile.txt" For Binary Access Read As #1
Buff = String(LOF(1), 0)
Get #1, , Buff
Count = Val(Buff) + 1
Open App.Path & "\TestFile.txt" For Binary Access Write As #1
Put #1, , CStr(Count)
Send "<html><body><h1>Hello world !</h1>"
Send "This page was loaded " & Count & " time" & IIf(Count = 1, "", "s") & "."
Private Function Send(ByVal Str As String) As Long
Dim lBytesWritten As Long
Str = Str & vbCrLf
WriteFile hStdOut, Str, Len(Str), lBytesWritten, ByVal 0&
Send = lBytesWritten