web development India freelance website designer
Prepared output is passed to the WriteSO function through the STD_OUTPUT_HANDLE, a
constant to obtain the handle associated with standard output. The handle writes standard output to
the web server when it is accessed via a URL.

Definitions:
hFile = Handle to the file to be written to.
lpBuffer Pointer to the buffer containing the data to be written to the file.
nNumberOfBytesToWrite = Number of bytes to write to the file.
lpNumberOfBytesWritten = Pointer to the number of bytes written by this function call.
lpOverlapped = Pointer to an OVERLAPPED structure, telling the file access functions what part of a
file to read or write when asynchronous.

---Code Sample---

Option Explicit
'Windows API Functions needed for proces ' sing stdin and WriteSO

Private Declare Function GetStdHandle Lib "Kernel32" ( _
ByVal nStdHandle As Long) As Long

'Get requested data using a writefile, the post method requires a call to readfile
Private Declare Function WriteFile Lib "Kernel32" ( _
ByVal hFile As Long, _
ByVal lpBuffer As Any, _
ByVal nNumberOfBytesToWrite As Long, _
lpNumberOfBytesWritten As Long, _
lpOverlapped As Any) As Long

' Constants needed by the Windows API functions
Private Const STD_INPUT_HANDLE = -10&
Private Const STD_OUTPUT_HANDLE = -11&

Public Function WriteSO(strOutput As String) As Long
Dim lngNumBytesWritten As Long
'on error resume next
WriteSO = 0
WriteSO = WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), _
strOutput & vbCrLf, _
Len(strOutput) + 2, _
lngNumBytesWritten, _
ByVal 0&)
End Function



Sub Main()
On Error GoTo EndMain
Dim strHeaders As String
Dim i

strHeaders = "Content-type: text/html" & vbCrLf & vbCrLf & "<--VB CGI-->" & vbCrLf

Do
i = i + 1
If Environ(i) = "" Then Exit Do
strHeaders = strHeaders & Environ(i)
strHeaders = strHeaders & "
"
Loop

WriteSO strHeaders

EndMain:
End

End Sub

CGI Template

1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700

Freelance ASP PHP web development | Web developer India Web development India| Prayagasoft - web designer India, Ecommerce developer india, Ecommerce design