void CCallieDlg::OnOK()
{
PROCESS_INFORMATION pi;
STARTUPINFO si;
si.cb = sizeof(STARTUPINFO);
si.lpReserved = NULL;
si.lpDesktop = NULL;
si.lpTitle = NULL;
si.dwFlags = 0;
si.cbReserved2 = 0;
si.lpReserved2 = NULL;
BOOL bres = CreateProcess(NULL,"C:\\Program Files\\Internet Explorer\\iexplore www.microsoft.com",NULL,NULL,false,
NORMAL_PRIORITY_CLASS,
NULL,NULL,&si,&pi);
if(bres==false)
{
AfxMessageBox("CreateProcess failed");
}
else
{
CloseHandle(pi.hThread);
DWORD dwret=WaitForSingleObject(pi.hProcess, 1000*30);
switch(dwret)
{
case WAIT_OBJECT_0:
DWORD dwexitcode;
bres = GetExitCodeProcess(pi.hProcess,&dwexitcode);
TCHAR exitmsgbuf[1024];
if(bres)
{
wsprintf(exitmsgbuf,"exit code:%d",dwexitcode);
}
else
wsprintf(exitmsgbuf,"exit code failed to return");
AfxMessageBox(exitmsgbuf);
break;
default:
AfxMessageBox("exit for other reason");
}
CloseHandle(pi.hProcess);
}
}
{
PROCESS_INFORMATION pi;
STARTUPINFO si;
si.cb = sizeof(STARTUPINFO);
si.lpReserved = NULL;
si.lpDesktop = NULL;
si.lpTitle = NULL;
si.dwFlags = 0;
si.cbReserved2 = 0;
si.lpReserved2 = NULL;
BOOL bres = CreateProcess(NULL,"C:\\Program Files\\Internet Explorer\\iexplore www.microsoft.com",NULL,NULL,false,
NORMAL_PRIORITY_CLASS,
NULL,NULL,&si,&pi);
if(bres==false)
{
AfxMessageBox("CreateProcess failed");
}
else
{
CloseHandle(pi.hThread);
DWORD dwret=WaitForSingleObject(pi.hProcess, 1000*30);
switch(dwret)
{
case WAIT_OBJECT_0:
DWORD dwexitcode;
bres = GetExitCodeProcess(pi.hProcess,&dwexitcode);
TCHAR exitmsgbuf[1024];
if(bres)
{
wsprintf(exitmsgbuf,"exit code:%d",dwexitcode);
}
else
wsprintf(exitmsgbuf,"exit code failed to return");
AfxMessageBox(exitmsgbuf);
break;
default:
AfxMessageBox("exit for other reason");
}
CloseHandle(pi.hProcess);
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货