共用方式為


IHttpCoNtext::GetServerVariable 方法

擷取特定的伺服器變數。

語法

virtual HRESULT GetServerVariable(  
   PCSTR pszVariableName,  
   PCWSTR * ppszValue,  
   DWORD * pcchValueLength  
) = 0;  
virtual HRESULT GetServerVariable(  
   PCSTR   pszVariableName,  
   PCSTR * ppszValue,  
   DWORD * pcchValueLength  
) = 0;  

參數

pszVariableName
字串的指標,其中包含要傳回的伺服器變數名稱。

ppszValue
接收伺服器變數複本之字串緩衝區的指標位址。

pcchValueLengthr
接收參數長度之緩衝區的 ppszValue 指標 DWORD

傳回值

HRESULT。 可能的值包括 (但不限於) 下表中的這些值。

描述
S_OK 表示作業成功。
ERROR_INVALID_INDEX 表示參數無效。

備註

方法 GetServerVariable 會從目前的 HTTP 內容中擷取 參數指定的 pszVariableName 伺服器變數,並傳回 參數所指向 ppszValue 之緩衝區中的值。 參數指定的 pszVariableName 伺服器變數可以是自訂變數或定義于要求 (RFC) 3875「通用閘道介面 (CGI) 1.1 版」中定義的變數。

注意

方法 GetServerVariable 支援透過多載方法傳回 ANSI 和 Unicode 值。 參數所指向的 ppszValue 緩衝區可以是 PCWSTRPCSTR 緩衝區。

規格需求

類型 描述
Client - Windows Vista 上的 IIS 7.0
- Windows 7 上的 IIS 7.5
- Windows 8 上的 IIS 8.0
- Windows 10上的 IIS 10.0
伺服器 - Windows Server 2008 上的 IIS 7.0
- Windows Server 2008 R2 上的 IIS 7.5
- Windows Server 2012 上的 IIS 8.0
- Windows Server 2012 R2 上的 IIS 8.5
- Windows Server 2016上的 IIS 10.0
產品 - IIS 7.0、IIS 7.5、IIS 8.0、IIS 8.5、IIS 10.0
- IIS Express 7.5、IIS Express 8.0、IIS Express 10.0
標頭 Httpserv.h

另請參閱

IHttpCoNtext 介面
IHttpCoNtext::SetServerVariable 方法