How to start a program until it runs?

xiaoxiao2021-03-06  41

ShellexecuteInfo shexecinfo = {0};

Shexecinfo.cbsize = sizeof (shellexecuteInfo);

Shexecinfo.fmask = see_mask_nocloseprocess;

Shexecinfo.hwnd = null;

Shexecinfo.lpverb = null;

Shexecinfo.lpfile = "c: //myprogram.exe";

Shexecinfo.lpparameters = ""

ShexecInfo.lpdirectory = null;

Shexecinfo.nshow = sw_show;

Shexecinfo.hinstapp = null;

ShellexecuteEx (& shexecInfo);

WaitforsingleObject (ShexecInfo.hprocess, Infinite);

Or: Process_information Processinfo;

StartupInfo Startupinfo; // this is an [in] parameter

ZeromeMory (& StartupInfo, Sizeof (StartupInfo);

Startupinfo.cb = sizeof startupinfo; // Only compulsory field

IF (CreateProcess ("C: //winnt//notepad.exe", null,

NULL, NULL, FALSE, 0, NULL,

NULL, & Startupinfo, & ProcessInfo)

{

WaitforsingleObject (ProcessInfo.hprocess, Infinite);

CloseHandle (ProcessInfo.hthread);

CloseHandle (ProcessInfo.hprocess);

}

Else

{

MessageBox ("The Process Could Not Be Started ...");

}

转载请注明原文地址:https://www.9cbs.com/read-69684.html

New Post(0)