获取环境变量
PTSTR pszValue = NULL;
PCTSTR pszVariableName = TEXT("JAVA_HOME");
// Get the size of the buffer that is required to store the value
DWORD dwResult = GetEnvironmentVariable(pszVariableName, pszValue, 0);
if (dwResult != 0)
{// Allocate the buffer to store the environment variable value
DWORD size = dwResult * sizeof(TCHAR);
pszValue = (PTSTR)malloc(size);
GetEnvironmentVariable(pszVariableName, pszValue, size);
_tprintf(TEXT("%s=%s\n"), pszVariableName, pszValue);
free(pszValue);
}
else
{
_tprintf(TEXT("'%s'=<unknown value>\n"), pszVariableName);
}
posted on 2013-07-14 10:55 Sunny_NUAA 阅读(248) 评论(0) 收藏 举报
浙公网安备 33010602011771号