I need to get temp path. So I tried GetTempPath() and std::getenv("TEMP"). The problem is that the result contains ~ symbol, for example C:\Users\OLEKSI~1.ALE\AppData\Local\Temp. Is it possible to get full temp path like C:\Users\Oleksii\AppData\Local\Temp?
CodePudding user response:
GetLongPathName
function:
Converts the specified path to its long form.
DWORD GetLongPathNameA(
[in] LPCSTR lpszShortPath,
[out] LPSTR lpszLongPath,
[in] DWORD cchBuffer
);
CodePudding user response:
According to the Microsoft documentation:
The GetTempPath function checks for the existence of environment variables in the following order and uses the first path found:
- The path specified by the TMP environment variable.
- The path specified by the TEMP environment variable.
- The path specified by the USERPROFILE environment variable.
- The Windows directory.
Have you checked what these are set to? In Windows 10 you can press Ctrl Break to open System Settings, then click Advanced system settings on the right, then click Environment Variables. If TMP, TEMP or USERPROFILE are in there, check that they are set correctly and don't have the unwanted ~
in them. If they're not, try adding them.