Consider we have this function:
#include <iostream>
#include <string>
#include <Windows.h>
#include <Winerror.h>
#include <Shlobj.h>
std::wstring get_common_appdata()
{
wchar_t buf[MAX_PATH + 1] = { 0 };
std::wstring path;
if (SUCCEEDED(SHGetFolderPathW(NULL, CSIDL_COMMON_APPDATA, NULL, SHGFP_TYPE_DEFAULT, buf)))
{
path = buf;
}
return path;
}
int main(int, char**)
{
std::wcout << get_common_appdata() << std::endl;
}
which typically while local debugging outputs:
C:\ProgramData
(on Windows 7/8.1/10).
But when remote debugging on remote (virtual) test machine (using Visual Studio 2013 Remote Debugger) it outputs:
%SystemDrive%\ProgramData
And when I run this simple program on virtual machine itself, it again returns correct
C:\ProgramData
Is it bug in WinAPI or it is already documented anywhere? How to deal with this behavior?