下面是在一个应用程序中调用另一个程序例子,下面代码可以运行C盘WINNT目录下的REGCHANG.EXE文件.
void CUpDateApp::RunRegChange()
{
STARTUPINFO si = ;
PROCESS_INFORMATION pi;
TCHAR szCommandLine[256];
::ZeroMemory( &si, sizeof( si ) );
::ZeroMemory( &pi, sizeof( pi ) );
_tcscpy( (TCHAR *)szCommandLine, _T("C:\WINNT\REGCHANG.EXE") );
BOOL bRet = ::CreateProcess( NULL, szCommandLine, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi );
if ( bRet )
{
::CloseHandle ( pi.hThread );
::WaitForSingleObject ( pi.hProcess , INFINITE );
::CloseHandle ( pi.hProcess );
}
}