在本地代码中使用Windows环境variables

// I have a permission to create a file to Program Files const std::wstring sFileName = L"%ProgramFiles%\\aaa.txt"; HANDLE h = CreateFileW( sFileName.c_str(), GENERIC_READ, FILE_SHARE_DELETE, 0, CREATE_ALWAYS, 0, 0); // INVALID_HANDLE_VALUE with ERROR_PATH_NOT_FOUND 

我期望它使得C:\ Program Files \ aaa.txtC:\ Program Files(x86)\ aaa.txt取决于Os的环境。 但它没有工作。
怎么了? 如何在本地代码中使用环境variables

Solutions Collecting From Web of "在本地代码中使用Windows环境variables"