CStringT::GetEnvironmentVariable

Sets the string to the value of the specified environment variable.

BOOL GetEnvironmentVariable(
   PCXSTR pszVar
);

pszVar

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

Nonzero if successful; otherwise 0.

Retrieves the value of the specified variable from the environment block of the calling process. The value is in the form of a null-terminated string of characters.

// typedef CStringT<TCHAR, StrTraitATL<TCHAR, ChTraitsCRT<TCHAR>>> CAtlString;
CAtlString EnvStr;

EnvStr.GetEnvironmentVariable(_T("TEMP"));
_tprintf_s(_T("Current value of TEMP variable: %s\n"), EnvStr);

Header: cstringt.h

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft