windows_programming_notes.nbk: Home | Index | Next Page: GetFileAttributes | Previous Page: GetEnvironmentStrings


 GetEnvironmentVariable

Retrieves the contents of the specified variable from the environment block of the calling process.

Syntax

    DWORD WINAPI GetEnvironmentVariable(
      __in_opt   LPCTSTR lpName,
      __out_opt  LPTSTR lpBuffer,
      __in       DWORD nSize
    );

Parameters

Return Value

If the function succeeds, the return value is the number of characters stored in the buffer pointed to by lpBuffer, not including the terminating null character.

If lpBuffer is not large enough to hold the data, the return value is the buffer size, in characters, required to hold the string and its terminating null character.

If the function fails, the return value is zero. If the specified environment variable was not found in the environment block, GetLastError returns ERROR_ENVVAR_NOT_FOUND.

Requirements


windows_programming_notes.nbk: Home | Index | Next Page: GetFileAttributes | Previous Page: GetEnvironmentStrings


Notebook exported on Monday, 7 July 2008, 18:56:50 PM Eastern Daylight Time