简体   繁体   中英

how to check if a program is started and running perfectly by windows service?

I have following code to start a program from my windows service. When the program has UI, I can see it running within session 0 but the process doesn't show up in task manager. So how can I know if a no-UI program is started by service and running perfectly?

SHELLEXECUTEINFO sei;
ZeroMemory( &sei, sizeof( SHELLEXECUTEINFO ) );
sei.cbSize = sizeof( SHELLEXECUTEINFO );
sei.fMask = 0;  
sei.lpVerb = NULL;
sei.nShow = SW_HIDE;
sei.lpFile = "display_A_Simple_Win32_Window.exe";   
sei.lpParameters=L"";
LPCTSTR mName = "name.exe";
hnd = CreateMutex(NULL, TRUE, mName);
if(GetLastError()==ERROR_ALREADY_EXISTS && WAIT_ABANDONED !=   WaitForSingleObject(hnd, 0x180)){
 ....................
    //name.exe was started//
 ................
            }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM