I am trying to call function CreateProcessAsUser. Passing constant string is fine. Trying to pick up an Environment variable using char* getenv(const char name) is causing me a problem.
If I use the following, notepad.exe will run.
CreateProcessAsUser(hTokenDup, _T("c:\\windows\\notepad.exe"),
_T("c:\\windows\\notepad.exe"), NULL, NULL, FALSE,
dwCreationFlag, pEnvironment, NULL, &si, &pi);
However, if I use the following nothing runs.
CreateProcessAsUser(hTokenDup, _T("MyAppName"),
(LPTSTR)getenv("MYENVVAR"), NULL, NULL, FALSE,
dwCreationFlag, pEnvironment, NULL, &si, &pi);
Have I specified the getenv and (LPTSTR) correctly?
I have tried using user and system environment vars containing c:\\windows\\notepad.exe and c:\windows\notepad.exe.
Thanks!