The Internet Client SDK includes a debug version of the WININET.DLL. The debug version of the library is capable of generating a wininet.log file in the current directory. This file can be used for debug purposes to view parameters passed to various API calls as well as viewing actual data sent and received by WinInet. To enable debugging follow these steps: 1. Rename the current wininet.dll in the %SystemRoot%\sytem32 on NT system directory or in %windir%\system directory for Windows 95 to wininet.org. 2. Copy the debug version of Wininet.dll to the %SystemRoot%\sytem32 for Windows NT or to %windir%\system directory for Windows 95 3. Reboot the system. The above steps are necessary because the shell process locks wininet.dll, so it can not be replaced when loaded. To generate a debug log file, start a command window and type "set wininetlog=1" at the prompt (without quotes). At this point any application using WinInet started from this command prompt will generate a corresponding log file. By default log file is called wininet.log. The log will be created in the application's current directory and will be replaced with each new execution of the application. Please note that application may change its current directory (by calling _chdir() C run time function, for example). Microsoft Internet Explorer (Iexplore.exe) changes default directory to desktop, so regardless directory where Iexplore.exe is started, default wininet.log file will be generated in the desktop directory. You can change this by setting environment/registry (see below about registry location) variable WininetLogFile, like this: "set wininetlogfile=c:\temp\MyNewLog.log". This variable can handle absolute/relative path semantics. Therefore, if you give an absolute path, you know exactly where the log file will be generated If the application is a service (on Windows NT for example) and can not be started from the command prompt, the wininetlog registry key of type REG_DWORD at: "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" controls logging behavior. Setting this variable to 1 enables logging, setting it to 0 disables it. A wininet.log file will be created in the application directory (i.e. in the directory of corresponding exe image for the service). As with the environment variable, WininetLogFile registry key of type REG_SZ controls name and location of the generated log file. If you set logging via registry, every wininet app that starts will try to generate the same log file unless individual WininetLogFile variables are specified for each application. This may result in a race condition. For this reason, setting WininetLog and WininetLogFile in the registry is less effective than creating environment variables, unless absolutely necessary. Please note that log files grow very rapidly and will degrade application performance. A simple WinInet application submitting one Http request via HttpSendRequest may easily generate about a 1 MB log file, please plan hard drive space accordingly. How to interpret the wininet.log file. The log file reflects APIs called directly from the WinInet.dll. Data sent/received by WinInet are also logged. Calls on each subsequent level will be indented to the right. Each API shows parameters either as a hex value (for addresses) or as an ASCII string. Setting environmental variable wininetlog=1 not only enables logging, bug also initializes default logging level (i.e. what and how should be logged). This explanation assumes default logging level. A typical line in the log file looks like this (all on one line): 16:27:55.759 00000108: 001 InternetOpenUrlA(0xcc0004, "http://corky", "Accept: */*\r\nAccept: image/gif\r\nAccept: image/jpeg\r\n\r\n", 54, 0x04000000, 0x0) The above line shows that the ASCII version of InternetOpenUrl has been called. Parameters to the call are shown as strings for the server name and headers and as hex values for handles and for option flags. Each line of the file is prefixed with following information: 1. Time stamp in following format: HH:MM:SS.SSS 2. Thread ID as a hexadecimal number. 00000108 in the above sample. 3. Asynchronous execution ID. In the above sample it is . Async. ID will be explained later in this document. 4. Call depth. In the sample above InternetOpenUrl was the first call. Asynchronous operation of WinInet. A programmer may choose to call WinInet.dll functions asynchronously. In this case calls that would normally block (such as HttpSendRequest) will immediately fail with error ERROR_IO_PENDING. Further progress of the asynchronous calls can be monitored via callback functions. Please see Internet Client SDK for more information on the asynchronous operation of WinInet. To handle asynchronous. requests WinInet creates a worker thread. This thread calls callback functions and also performs scheduling of submitted requests. The log file reflects the status of the asynchronous requests via its ID as follows: 1. - call from the application thread. 2. - async worker thread calling back into the app; any WinInet API requests during this time treated as though from the app context 3. <-----> - internal call performed by WinInet for the purpose of scheduling asynchronous requests. 4. - where XXXXX is a decemal number, reflecting the asynchronous ID. Debugging tips. The debug facility of WinInet generates a wealth of information that should be used wisely. If WinInet uses an SSL/PCT connection, the log will show clear text sent and received from the server. The log for multithreaded applications with many asynchronous calls may be very complex. To aid the debugging process you can parse the entire log by thread id. This will allow you to see what happens in a specific thread (remember that the asynchronous id for application threads will have the stamp). Multiple threads can share one HINTERNET handle. In this case parsing the entire log by the handle value can show the handle lifetime: from opening it to calling InternetCloseHandle. Note that this may spawn multiple threads. Don't forget to restore the original wininet.dll upon completion of a debugging session.