Per recent documentation, GetTempPath2W() should be attempted before using GetTempPathW(). https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-gettemppathw#remarks