| title | IHttpContext::GetServerVariable Method |
|---|---|
| description | Learn how the GetServerVariable method retrieves a specific server variable. |
| ms.date | 10/07/2016 |
| ms.assetid | 7771e6fa-b157-4df6-5e6b-97749a3c9fdb |
Retrieves a specific server variable.
virtual HRESULT GetServerVariable(
PCSTR pszVariableName,
PCWSTR * ppszValue,
DWORD * pcchValueLength
) = 0;
virtual HRESULT GetServerVariable(
PCSTR pszVariableName,
PCSTR * ppszValue,
DWORD * pcchValueLength
) = 0; pszVariableName
A pointer to a string that contains the name of the server variable to return.
ppszValue
The address of a pointer to a string buffer that receives a copy of the server variable.
pcchValueLengthr
A pointer to a DWORD buffer that receives the length of the ppszValue parameter.
An HRESULT. Possible values include, but are not limited to, those in the following table.
| Value | Description |
|---|---|
| S_OK | Indicates that the operation was successful. |
| ERROR_INVALID_INDEX | Indicates that the parameter is not valid. |
The GetServerVariable method retrieves a server variable specified by the pszVariableName parameter from the current HTTP context, and it returns the value in a buffer pointed to by the ppszValue parameter. The server variable specified by the pszVariableName parameter can be a custom variable or a variable defined in Requests for Comments (RFC) 3875, "The Common Gateway Interface (CGI) Version 1.1."
Note
The GetServerVariable method supports returning both ANSI and Unicode values through overloaded methods. The buffer pointed to by the ppszValue parameter can be either a PCWSTR or PCSTR buffer.
| Type | Description |
|---|---|
| Client | - IIS 7.0 on [!INCLUDEwinvista] - IIS 7.5 on Windows 7 - IIS 8.0 on Windows 8 - IIS 10.0 on Windows 10 |
| Server | - IIS 7.0 on [!INCLUDEwinsrv2008] - IIS 7.5 on Windows Server 2008 R2 - IIS 8.0 on Windows Server 2012 - IIS 8.5 on Windows Server 2012 R2 - IIS 10.0 on Windows Server 2016 |
| Product | - IIS 7.0, IIS 7.5, IIS 8.0, IIS 8.5, IIS 10.0 - [!INCLUDEiisexp75], [!INCLUDEiisexp80], [!INCLUDEiisexp100] |
| Header | Httpserv.h |
IHttpContext Interface
IHttpContext::SetServerVariable Method