14. Windows CGI
Contents:
Many Windows-based Web servers use a modified CGI interface that allows users to write CGI programs in native Windows programming environments, such as Visual Basic, Delphi, or Visual C++. While many of the CGI basics still apply, WinCGI has its own implementation, covered in this chapter. See Chapter 9, CGI Overview, for basic CGI information. Since the UNIX concepts of standard input and environment variables are foreign to Microsoft Windows, WinCGI-compliant servers transfer data to the program using external temporary files. CGI programs can then retrieve CGI information directly from these files, or they can use a framework such as the CGI.BAS module supplied for Visual Basic programmers using the WebSite server. This chapter covers the generic WinCGI interface as well as the variables and functions defined on the WebSite server for Visual Basic programming. 14.1 The Windows CGI Framework for Visual BasicThe WebSite server is distributed with CGI.BAS and CGI32.BAS modules, to facilitate CGI programming under (respectively) Visual Basic Version 3 and Visual Basic Version 4. The framework module defines the Main() routine of the program, CGI variables for use by the program, and several functions for simplifying CGI programming and error handling. The Main( ) RoutineProjects you create for CGI programs that use the framework should be set to start in Sub Main() (rather than in a form). When the CGI program starts, it enters at Main() in the framework. The framework extracts all of the variables, special request headers, and form content, if any, and stores them in global variables. It also establishes a global exception handler (On Error) so that runtime errors in your CGI program are trapped, preventing the CGI program from exiting without producing a response. Once the CGI environment has been set up, the framework calls a routine called CGI_Main() that you must write. This is where your code starts. Always return from CGI_Main(). Never do an abort or exit within a CGI program using the framework. If the CGI executable is double-clicked, it will not have the correct information on its command line (no INI file). If this happens, the Main() routine calls a routine Inter_Main(), which you must also write. For most applications, simply display a message box telling the user that this is a CGI program, then exit. CGI VariablesThe CGI32.BAS module defines variables for use within the CGI program. Information About the Server
Information About the Browser or User
Information About the Request
Miscellaneous
Utility FunctionsThe CGI32.BAS module defines these functions for facilitating CGI programming, which give information about the server:
|
|