| |
| DWORD WINAPI HttpGetProgramOutput( |
| |
HSERVER hServer, |
|
| |
UINT nClientId, |
|
| |
LPBYTE lpBuffer, |
|
| |
DWORD dwBufferSize |
|
| ); |
Return a copy of the standard output from a CGI program
executed by the client.
Parameters
- hServer
- The server handle.
- nClientId
- An unsigned integer which uniquely identifies the client
session.
- lpBuffer
- A buffer that will contain the output from the last
program executed by the client. If this parameter is NULL, the
function will return the number of bytes of data that was output by
the program. Note that this output is not null-terminated.
- dwBufferSize
- The maximum number of bytes that can be copied into the buffer.
If the lpBuffer parameter is NULL, this value should be zero.
Return Value
If the function succeeds, the return value is the number of
bytes copied into the specified buffer. If the
server handle and client ID do not specify a valid client session,
the function will return zero. If the client has not executed any
programs, the return value will be zero.
Remarks
The HttpGetProgramOutput function is used to obtain a copy of
the output generated by a CGI program. To determine the number of bytes
of output available to read, call this function with the lpBuffer
parameter as NULL and the dwBufferSize parameter with a value of
zero. The return value will be the number of bytes of data that was
output by the program. It should be noted that for Unicode builds, the
buffer is a byte array, not an array of characters, and will not be null
terminated.
This function returns the raw output from the program which may contain
a response header block, escape sequences, control characters and embedded
nulls. When the application processes the output returned by this function,
it should never coerce the buffer pointer to an LPTSTR value because
there is no guarantee that the data will be null-terminated. To obtain
the output from the program as a string, use the
HttpGetProgramText function.
This function should only be used within an HTTP_CLIENT_EXECUTE
event handler, which occurs after the program has terminated.
Example
LPBYTE lpBuffer = NULL; // The output buffer
DWORD cbBuffer = 0; // Number of bytes in the output buffer
// Determine the number of bytes in the output buffer
cbBuffer = HttpGetProgramOutput(hServer, nClientId, NULL, 0);
if (cbBuffer > 0)
{
// Allocate memory for the buffer
lpBuffer = (LPBYTE)LocalAlloc(LPTR, cbBuffer + 1);
// Copy the program output to the buffer
if (lpBuffer != NULL)
cbBuffer = HttpGetProgramOutput(hServer, nClientId, lpBuffer, cbBuffer + 1);
}
// Free the memory allocated for the buffer when finished
if (lpBuffer != NULL)
{
LocalFree((HLOCAL)lpBuffer);
lpBuffer = NULL;
cbBuffer = 0;
}
Requirements
Minimum Desktop Platform: Windows 7 Service Pack 1
Minimum Server Platform: Windows Server 2008 R2 Service Pack 1
Header File: cstools12.h
Import Library: cshtsv12.lib
See Also
|
|