Chinaunix

标题: 请教ShExecInfo和WaitForSingleObject的问题,谢谢 [打印本页]

作者: lordports    时间: 2012-05-30 22:03
标题: 请教ShExecInfo和WaitForSingleObject的问题,谢谢
程序在WaitForSingleObject时候挂住了,cmd的命令已经执行完了,cmd中就执行了远端shell脚本的chmod命令,应该很快就返回值了,可是等了几个小时WaitForSingleObject也没有等待消息,远端的进程已经没有了。
SHELLEXECUTEINFO   ShExecInfo   =   {0};
ShExecInfo.cbSize   =   sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask   =   SEE_MASK_NOCLOSEPROCESS;
ShExecInfo.hwnd   =   NULL;
ShExecInfo.lpVerb   =   NULL;
ShExecInfo.lpFile   =   "cmd.exe ";
ShExecInfo.lpParameters   =   " ";
ShExecInfo.lpDirectory   =   NULL;
ShExecInfo.nShow   =   SW_SHOW;
ShExecInfo.hInstApp   =   NULL;
ShellExecuteEx(&ShExecInfo);
WaitForSingleObject(ShExecInfo.hProcess,INFINITE);
作者: bruceteen    时间: 2012-05-31 08:22
代码没问题,你等待的是cmd.exe这个进程退出,而不是chmod这个命令

cmd.exe /C chmod




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2