GetEnvironmentVariable

  DWORD GetEnvironmentVariable(lpszName, lpszReturn, cchReturn)    
  LPTSTR lpszName; /* name of environment variable */
  LPTSTR lpszReturn; /* address of buffer for variable value */
  DWORD cchReturn; /* size of buffer in characters */

The GetEnvironmentVariable function retrieves the specified variable from the environment block for the current process.

Parameters

lpszName

Points to a null-terminated string that specifies the environment variable.

lpszReturn

Points to a buffer for the value of the specified environment variable.

cchReturn

Specifies the size of the buffer at lpszReturn (in characters).

Return Value

If the function is successful, the return value is the number of characters stored in lpszReturn, not including the terminating null character. The return value is zero if the environment variable name was not found in the environment block for the current process.

Comments

The GetEnvironmentVariable function may be used as either a wide-character function (where text arguments must use Unicode) or an ANSI function (where text arguments must use characters from the Windows 3.x character set installed).

See Also

SetEnvironmentVariable