if(ShellExecute (NULL,"open","encryptfile.exe","c:\\check.txt -o c:\\result.dat",NULL,SW_SHOW) >=(HANDLE) 32)
{
//对result.dat进行处理
}
4 个解决方案
#1
用进程句柄来同步试试
#2
用CreateProcess来执行一个EXE,用WaitForSingleObject来进行等待
#3
CreateProcess encryptfile.exe
然后等待进程句柄,直到进程退出后再往下走.
然后等待进程句柄,直到进程退出后再往下走.
#4
SHELLEXECUTEINFO ShExecInfo = {0};
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
ShExecInfo.hwnd = NULL ;
ShExecInfo.lpVerb =NULL;
ShExecInfo.lpFile = "cmd.exe";
ShExecInfo.lpParameters = m_set;
ShExecInfo.lpDirectory = NULL;
ShExecInfo.nShow = SW_HIDE;
ShExecInfo.hInstApp = NULL;
ShellExecuteEx(&ShExecInfo);
int ret=WaitForSingleObject(ShExecInfo.hProcess,INFINITE);
if(ret!=WAIT_TIMEOUT)
{
AfxMessageBox("done");
}
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
ShExecInfo.hwnd = NULL ;
ShExecInfo.lpVerb =NULL;
ShExecInfo.lpFile = "cmd.exe";
ShExecInfo.lpParameters = m_set;
ShExecInfo.lpDirectory = NULL;
ShExecInfo.nShow = SW_HIDE;
ShExecInfo.hInstApp = NULL;
ShellExecuteEx(&ShExecInfo);
int ret=WaitForSingleObject(ShExecInfo.hProcess,INFINITE);
if(ret!=WAIT_TIMEOUT)
{
AfxMessageBox("done");
}
#1
用进程句柄来同步试试
#2
用CreateProcess来执行一个EXE,用WaitForSingleObject来进行等待
#3
CreateProcess encryptfile.exe
然后等待进程句柄,直到进程退出后再往下走.
然后等待进程句柄,直到进程退出后再往下走.
#4
SHELLEXECUTEINFO ShExecInfo = {0};
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
ShExecInfo.hwnd = NULL ;
ShExecInfo.lpVerb =NULL;
ShExecInfo.lpFile = "cmd.exe";
ShExecInfo.lpParameters = m_set;
ShExecInfo.lpDirectory = NULL;
ShExecInfo.nShow = SW_HIDE;
ShExecInfo.hInstApp = NULL;
ShellExecuteEx(&ShExecInfo);
int ret=WaitForSingleObject(ShExecInfo.hProcess,INFINITE);
if(ret!=WAIT_TIMEOUT)
{
AfxMessageBox("done");
}
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
ShExecInfo.hwnd = NULL ;
ShExecInfo.lpVerb =NULL;
ShExecInfo.lpFile = "cmd.exe";
ShExecInfo.lpParameters = m_set;
ShExecInfo.lpDirectory = NULL;
ShExecInfo.nShow = SW_HIDE;
ShExecInfo.hInstApp = NULL;
ShellExecuteEx(&ShExecInfo);
int ret=WaitForSingleObject(ShExecInfo.hProcess,INFINITE);
if(ret!=WAIT_TIMEOUT)
{
AfxMessageBox("done");
}