两种方法: ShellExecuteEx CreateProcessHANDLE RunApplication(LPCTSTR szAppName) { SHELLEXECUTEINFO ExecuteInfo; ExecuteInfo.cbSize = sizeof( ExecuteInfo ); ExecuteInfo.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_NO_UI; ExecuteInfo.hwnd = NULL; ExecuteInfo.lpVerb = _T("open"); ExecuteInfo.lpFile = szAppName; ExecuteInfo.lpParameters = NULL; ExecuteInfo.lpDirectory = NULL; ExecuteInfo.nShow = SW_SHOWMAXIMIZED; BOOL bResult = ShellExecuteEx( &ExecuteInfo ); if( !bResult && (int)ExecuteInfo.hInstApp <= 32 ) { return NULL; } return ExecuteInfo.hProcess;}BOOL m_result=CreateProcess( strPath,// pointer to name of executable module theApp.m_ProgramRunPara.GetAt(index), // pointer to command line string NULL, // process security attributes NULL, // thread security attributes FALSE, // handle inheritance flag 0, // creation flags NULL, // pointer to new environment block NULL, // pointer to current directory name NULL, // pointer to STARTUPINFO &ProcessInformation ); // pointer to PROCESS_INFORMATION
WinExec The WinExec function runs the specified application. This function is provided for compatibility with 16-bit Windows. Win32-based applications should use the CreateProcess function. UINT WinExec( LPCSTR lpCmdLine, // address of command line UINT uCmdShow // window style for new application );
ShellExecuteEx
CreateProcessHANDLE RunApplication(LPCTSTR szAppName)
{
SHELLEXECUTEINFO ExecuteInfo;
ExecuteInfo.cbSize = sizeof( ExecuteInfo );
ExecuteInfo.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_NO_UI;
ExecuteInfo.hwnd = NULL;
ExecuteInfo.lpVerb = _T("open");
ExecuteInfo.lpFile = szAppName;
ExecuteInfo.lpParameters = NULL;
ExecuteInfo.lpDirectory = NULL;
ExecuteInfo.nShow = SW_SHOWMAXIMIZED; BOOL bResult = ShellExecuteEx( &ExecuteInfo ); if( !bResult && (int)ExecuteInfo.hInstApp <= 32 )
{
return NULL;
}
return ExecuteInfo.hProcess;}BOOL m_result=CreateProcess(
strPath,// pointer to name of executable module
theApp.m_ProgramRunPara.GetAt(index), // pointer to command line string
NULL, // process security attributes
NULL, // thread security attributes
FALSE, // handle inheritance flag
0, // creation flags
NULL, // pointer to new environment block
NULL, // pointer to current directory name
NULL, // pointer to STARTUPINFO
&ProcessInformation ); // pointer to PROCESS_INFORMATION
The WinExec function runs the specified application. This function is provided for compatibility with 16-bit Windows. Win32-based applications should use the CreateProcess function. UINT WinExec(
LPCSTR lpCmdLine, // address of command line
UINT uCmdShow // window style for new application
);
PROCESS_INFORMATION pi;
STARTUPINFO si;
memset(&si,0,sizeof(si));
si.cb=sizeof(si);
si.wShowWindow=SW_SHOW;
si.dwFlags=STARTF_USESHOWWINDOW;
CreateProcess(NULL,(LPSTR)aaa,NULL,NULL, FALSE,NORMAL_PRIORITY_CLASS|CREATE_NEW_CONSOLE,
NULL,NULL,&si,&pi);
ShellExecute(
HWND hwnd, //父窗口句柄,可谓NULL
LPCTSTR lpVerb, //操作
LPCTSTR lpFile, //文件名,程序名
LPCTSTR lpParameters, //参数
LPCTSTR lpDirectory, //目录
INT nShowCmd //显示方式
);
你看一下这个文章:http://www.vckbase.com/document/viewdoc.asp?id=416