The %USERPROFILE%\AppData\Local\Temp\
path IS the correct TEMP
folder you should be using in most situations. That is the folder that APIs like getenv("%TEMP%"|"%TMP%")
and GetTempPath()
return on a per-user basis, by design. You should not be using the C:\Windows\Temp\
folder at all, as that is a system folder meant for Windows' internal use.
That being said, if you really want to get the system %TEMP%
path, then you can either:
obtain the path of the Windows installation folder by using getenv("%WINDIR%"|"%SYSTEMROOT%")
, GetWindowsDirectory()
, SHGetFolderPath(CSIDL_WINDOWS)
, or SHGetKnownFolderPath(FOLDERID_Windows)
, and then append Temp
to the end of that path.
read the "TEMP"
or "TMP"
value in the HKLM\System\CurrentControlSet\Control\Session Manager\Environment
Registry key.