EDN Admin
Well-known member
Hello I am using CreateProcessAsUser function to run a gui application from my windows service, I look at my application in the task manager but the application dont show on the desktop, why?? I am using Windows 7. and the thes is the code
BOOL StartProcess(int ProcessIndex)<br/>
{<br/>
<br/>
STARTUPINFO startUpInfo = { sizeof(STARTUPINFO),NULL,"",NULL,0,0,0,0,0,0,0,STARTF_USESHOWWINDOW,0,0,NULL,0,0,0};
<br/>
startUpInfo.wShowWindow = SW_SHOW;<br/>
startUpInfo.lpDesktop = NULL;<br/>
<br/>
HANDLE hToken;<br/>
HDESK hdesk = NULL;<br/>
PROCESS_INFORMATION pi;<br/>
STARTUPINFO si;<br/>
BOOL bResult = FALSE;<br/>
ZeroMemory(&si, sizeof(STARTUPINFO));<br/>
si.cb= sizeof(STARTUPINFO);<br/>
si.lpDesktop = TEXT("winsta0\default");<br/>
<br/>
<br/>
bResult = CreateProcessAsUser(<br/>
NULL,
<br/>
ProcessNames[ProcessIndex], // here is the full path of mi applicati<br/>
NULL, <br/>
NULL, <br/>
NULL, <br/>
FALSE, <br/>
NORMAL_PRIORITY_CLASS | CREATE_NEW_CONSOLE,
<br/>
NULL,
<br/>
NULL,
<br/>
&startUpInfo, <br/>
&pProcInfo[ProcessIndex]
<br/>
); <br/>
<br/>
<br/>
if(bResult)<br/>
{<br/>
WriteLog(pLogFile, "Process create succefull");<br/>
Sleep(1000);<br/>
return TRUE;<br/>
}<br/>
else<br/>
{<br/>
long nError = GetLastError();<br/>
char pTemp[256];<br/>
sprintf(pTemp,"Failed to start program %s, error code = %dn", ProcessNames[ProcessIndex], nError);
<br/>
WriteLog(pLogFile, pTemp);<br/>
return FALSE;<br/>
}<br/>
}<br/>
<br/>
View the full article
BOOL StartProcess(int ProcessIndex)<br/>
{<br/>
<br/>
STARTUPINFO startUpInfo = { sizeof(STARTUPINFO),NULL,"",NULL,0,0,0,0,0,0,0,STARTF_USESHOWWINDOW,0,0,NULL,0,0,0};
<br/>
startUpInfo.wShowWindow = SW_SHOW;<br/>
startUpInfo.lpDesktop = NULL;<br/>
<br/>
HANDLE hToken;<br/>
HDESK hdesk = NULL;<br/>
PROCESS_INFORMATION pi;<br/>
STARTUPINFO si;<br/>
BOOL bResult = FALSE;<br/>
ZeroMemory(&si, sizeof(STARTUPINFO));<br/>
si.cb= sizeof(STARTUPINFO);<br/>
si.lpDesktop = TEXT("winsta0\default");<br/>
<br/>
<br/>
bResult = CreateProcessAsUser(<br/>
NULL,
<br/>
ProcessNames[ProcessIndex], // here is the full path of mi applicati<br/>
NULL, <br/>
NULL, <br/>
NULL, <br/>
FALSE, <br/>
NORMAL_PRIORITY_CLASS | CREATE_NEW_CONSOLE,
<br/>
NULL,
<br/>
NULL,
<br/>
&startUpInfo, <br/>
&pProcInfo[ProcessIndex]
<br/>
); <br/>
<br/>
<br/>
if(bResult)<br/>
{<br/>
WriteLog(pLogFile, "Process create succefull");<br/>
Sleep(1000);<br/>
return TRUE;<br/>
}<br/>
else<br/>
{<br/>
long nError = GetLastError();<br/>
char pTemp[256];<br/>
sprintf(pTemp,"Failed to start program %s, error code = %dn", ProcessNames[ProcessIndex], nError);
<br/>
WriteLog(pLogFile, pTemp);<br/>
return FALSE;<br/>
}<br/>
}<br/>
<br/>
View the full article