char *lpszAppPath=TEXT("C:\\WINDOWS\\system32\\notepad.exe");
char *szPath =TEXT("C:\\1.txt ");
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
ZeroMemory(&pi, sizeof(pi));
CreateProcess(lpszAppPath, // Module name.
szPath, //命令行参数.
NULL,
NULL,
FALSE,
1,
NULL,
NULL,
&si,
&pi);
// Close process and thread handles
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
------解决方案--------------------------------------------------------
char *lpszAppPath="C:\\WINDOWS\\system32\\notepad.exe C:\\1.txt";
char *szPath ="C:\\1.txt ";
int main()
{
STARTUPINFO si;
memset(&si,0,sizeof(STARTUPINFO));
si.cb = sizeof(STARTUPINFO);
si.wShowWindow = TRUE;
si.dwFlags = STARTF_USESHOWWINDOW;
PROCESS_INFORMATION pi;
BOOL bRet =CreateProcess(NULL, // Module name.
lpszAppPath, //命令行参数.
NULL,
NULL,
FALSE,
0,
NULL,
NULL,
&si,
&pi);
// Close process and thread handles
if(bRet)
{
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
}
system("pause");
}