Something like SendMessage(HWND_BROADCAST,WM_WININICHANGE,0,"Environment") is your best bet, but most applications will ignore it, but Explorer should handle it.
Something like SendMessage(HWND_BROADCAST,WM_WININICHANGE,0,"Environment") is your best bet, but most applications will ignore it, but Explorer should handle it. If you want to go into crazy undocumented land, you could use WriteProcessMemory and update the environment block in every process you have access to.
Interesting, indeed, It seems to be impossible to oblige a running process to update its environment variable, except if it was previously planned. – TaintedLove Aug 12 '09 at 8:35.
I would agree with you if I had never ear something about the propagation of a Windows modified variable by the command line: net – TaintedLove Aug 10 '09 at 9:19.
Yes, this is possible. Method It is involved though. I'll outline the basic steps.
The detail for each step is documented in many places on the web, including Stack Overflow. Create a helper dll. The dll does nothing except set the environment variables you want to set.It can do this from DllMain without causing any problems.
Just don't got mad with other function calls from inside DllMain. How you communicate to the DLL what variables to set and what values to set them is left for you to decide (read a file, read from registry...) Enumerate all processes that you wish to update (toolhelp32 will help with this). For each process you wish to update, inject your helper dll.
CreateRemoteThread() will help with this. This will fail for 2% of all apps on NT 4, rising to 5% on XP. Most likely higher percentage failures for Vista/7 and the server versions.
Things you have to live with: If you are running a 32 bit process on a 64 bit OS, CreateRemoteThread will fail to inject your DLL into 32 bit apps 100% of the time (and cannot inject into 64 bit apps anyway as that is a job for a 64 bit app). Don't remain resident If you don't want your helper DLL to remain resident in the target application, return FALSE for the DLL_PROCESS_ATTACH notification. BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { if (ul_reason_for_call == DLL_PROCESS_ATTACH) { // set our env vars here SetEnvironmentVariable("weebles", "wobble but they don't fall down"); // we don't want to remain resident, our work is done return FALSE; } return TRUE; }.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.