GetEnvironmentVariable

GetEnvironmentVariable是一個從調用該函式的進程的環境變數中返回指定的變數名值的函式,主要參數有lpName、lpBuffer等。

GetEnvironmentVariable函式從調用該函式的進程的環境變數中,返回指定的變數名的值,該值是一個以零結尾的字元串指針.
DWORD GetEnvironmentVariable(
LPCTSTR lpName, // address of environment variable name
LPTSTR lpBuffer, // address of buffer for variable value
DWORD nSize // size of buffer, in characters
);
參數:
lpName:要獲取值的變數名字元串指針.
lpBuffer:接收變數值的字元串指針
nSize:接收變數值的記憶體大小.
返回值:
如果函式成功執行,則返回值是寫入字元緩衝區的字元數量,但不包含'\0'字元.
如果沒有找到所指的變數,則返回零.
如果字元緩衝區的大小小於變數值的長度,返回值為緩衝區的大小.
速查:
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: Unsupported.
Header: Declared in winbase.h.
Import Library: Use kernel32.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT.
另請參閱:
Processes and Threads Overview, Process and Thread Functions, GetEnvironmentStrings, SetEnvironmentVariable

相關詞條

熱門詞條

聯絡我們