Hello friends, I want to develope a software which can run for standard users. My software will be installed for only for current user. My superior wants me to keep read only files(Exe ,Dlls...) in Program files path. Other data files in Appdata path,Since those files required Read & write access. Ex: Lets consider two user accounts in a PC. 1) administrator 2) joe ( standard user) Now the user logged in as a joe and trying to install the software. So my setup file asks for elevation becoz it has to put files in program files path. Once the installer has got elevated ,after that if i am getting Environment variable "AppData" to put the data files. It gives me "C:\users\administrator\Appdata\Roaming\" path, but actually i have to put the files for user joe. I dont know how to get the currently logged in users Profile directory. Note: After the elevation . if I am getting the HKCU profile that also gives me the administrator profile only. Try outs: I was loggin as a Joe ( standard user)and launching the setup file.Setup file asks for elevation. From My setup file(runs in administrator account after elevation), I tried to find "expolrer.exe" (runs in Joe account) and getting it is ProcessToken and CreateEnvironmentBlock fn to create environment block for the Explorer.exe. In Vista it is succeeding but in XP OpenProcess fails if i am elevating the exe and trying to get info from the Explorer.exe which runs in Joe's account.
HANDLE hProcessHandle = OpenProcess(PROCESS_QUERY_INFORMATION,FALSE,dwExploererProcessId);
if( hProcessHandle == NULL)
return -2;
int nRetVal = OpenProcessToken(hProcessHandle,TOKEN\_QUERY,&hToken);
if(nRetVal == 0 )
return -3;
BOOL bval = CreateEnvironmentBlock(&lpData,hToken,FALSE);
if(bval == FALSE)
return -4;
Advice me about the correct way to get the Currently logged in users profile directory. Eagerly waiting for your answers. Thanks , WindowsPistha