Export (0) Print
Expand All

CStringT::GetEnvironmentVariable 

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


BOOL GetEnvironmentVariable(
   PCXSTR pszVar
);

Parameters

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.

// cstringt_getenvironmentvariable.cpp    
#include <string.h>
#include <atlsimpstr.h>
#include <atlstr.h>

int main(int argc, char* argv[])
{
    //typedef CStringT< TCHAR, StrTraitATL< TCHAR > > CAtlString;
    CAtlString EnvStr;

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

   return 0;
}

Community Additions

ADD
Show:
© 2014 Microsoft