//////////////////////CreateProcess()///////////////////////////////// CString str; STARTUPINFO si; PROCESS_INFORMATION pi; // 调用的应用程序名 str = "Ping"; //"Ping.exe" // zero out and initialize STARTUPINFO memset( &si, 0, sizeof( si ) ); si.cb = sizeof( si ); si.dwFlags = STARTF_USESHOWWINDOW; si.wShowWindow = SW_SHOW; if(CreateProcess( NULL, // can be name of process unless // batch file, else must be // in command line: (char*)LPCSTR(str), // command line NULL,NULL, // security options FALSE, // if true will inherit all // inheritable handles // from this process NORMAL_PRIORITY_CLASS, // can also be HIGH_PRIORITY_CLASS // or IDLE_PRIORITY_CLASS NULL, // inherit this process's // environment block NULL, // specifies working directory // of created process &si, // STA RTUPINFO specified above &pi // PROCESS_INFORMATION returned ) ) { // HANDLE pH = pi.hProcess; // // wait until application is ready for input // if ( !WaitForInputIdle( pH,1000 ) ) // { // // send messages, etc. // } // kill process with 0 exit code // TerminateProcess( pH, 0 ); } else { AfxMessageBox( "Ping.exe 文件当前目录不存在!" ); }
::ShellExecute(NULL,NULL,"iexplore","www.263.net",NULL,SW_SHOWNORMAL);
CString str;
STARTUPINFO si;
PROCESS_INFORMATION pi; // 调用的应用程序名
str = "Ping"; //"Ping.exe" // zero out and initialize STARTUPINFO
memset( &si, 0, sizeof( si ) );
si.cb = sizeof( si );
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_SHOW;
if(CreateProcess(
NULL, // can be name of process unless
// batch file, else must be
// in command line:
(char*)LPCSTR(str), // command line
NULL,NULL, // security options
FALSE, // if true will inherit all
// inheritable handles
// from this process
NORMAL_PRIORITY_CLASS, // can also be HIGH_PRIORITY_CLASS
// or IDLE_PRIORITY_CLASS
NULL, // inherit this process's
// environment block
NULL, // specifies working directory
// of created process
&si, // STA RTUPINFO specified above
&pi // PROCESS_INFORMATION returned
)
)
{
// HANDLE pH = pi.hProcess;
// // wait until application is ready for input
// if ( !WaitForInputIdle( pH,1000 ) )
// {
// // send messages, etc.
// }
// kill process with 0 exit code
// TerminateProcess( pH, 0 );
}
else
{
AfxMessageBox( "Ping.exe 文件当前目录不存在!" );
}