打开进程,等操作 openProcess
2012-05-18 15:54
281 查看
E:\EClient\复件打包配置2\setup (工程:)
BOOL CSetupDlg::OpenProcess(CString lpCmd , DWORD dwWaitTime )
{
STARTUPINFO stinfo;
PROCESS_INFORMATION procinfo;
memset(&stinfo,0,sizeof(stinfo));
stinfo.cb = sizeof(stinfo);
memset(&procinfo,0,sizeof(PROCESS_INFORMATION));
stinfo.dwFlags = STARTF_USESHOWWINDOW;
stinfo.wShowWindow = SW_HIDE;
CreateProcess( NULL , (LPWSTR)(LPCTSTR)lpCmd, NULL, NULL, FALSE,
NORMAL_PRIORITY_CLASS, NULL, NULL, &stinfo, &procinfo);
//MessageBox(_T("hello,openprocess"));
if (NULL == procinfo.hProcess)
return FALSE;
if (WaitForSingleObject(procinfo.hProcess , dwWaitTime) == WAIT_TIMEOUT)
return FALSE;
return TRUE;
}
//删除文件
void CSetupDlg::DeleteFiles()
{
OnTestlistctrlBtn();
if(0 == nAmountFiles)
{
MessageBox(_T("没有选择要删除的文件"));
return ;
}
CFileFind FileFind;
CString m_strde;
BOOL bFound;
for(int i = 0; i < nAmountFiles; i++)
{
m_strde = strDest[i];
bFound = FileFind.FindFile(m_strde, 0);
if(bFound)
{
OpenProcess("cmd.exe /c del \"" + m_strde + "\"" );
//MessageBox(m_strde);
}
}
// OpenProcess("cmd.exe /c del \"" + FileFind.GetFilePath() + "\"" , 500);
}
BOOL CSetupDlg::OpenProcess(CString lpCmd , DWORD dwWaitTime )
{
STARTUPINFO stinfo;
PROCESS_INFORMATION procinfo;
memset(&stinfo,0,sizeof(stinfo));
stinfo.cb = sizeof(stinfo);
memset(&procinfo,0,sizeof(PROCESS_INFORMATION));
stinfo.dwFlags = STARTF_USESHOWWINDOW;
stinfo.wShowWindow = SW_HIDE;
CreateProcess( NULL , (LPWSTR)(LPCTSTR)lpCmd, NULL, NULL, FALSE,
NORMAL_PRIORITY_CLASS, NULL, NULL, &stinfo, &procinfo);
//MessageBox(_T("hello,openprocess"));
if (NULL == procinfo.hProcess)
return FALSE;
if (WaitForSingleObject(procinfo.hProcess , dwWaitTime) == WAIT_TIMEOUT)
return FALSE;
return TRUE;
}
//删除文件
void CSetupDlg::DeleteFiles()
{
OnTestlistctrlBtn();
if(0 == nAmountFiles)
{
MessageBox(_T("没有选择要删除的文件"));
return ;
}
CFileFind FileFind;
CString m_strde;
BOOL bFound;
for(int i = 0; i < nAmountFiles; i++)
{
m_strde = strDest[i];
bFound = FileFind.FindFile(m_strde, 0);
if(bFound)
{
OpenProcess("cmd.exe /c del \"" + m_strde + "\"" );
//MessageBox(m_strde);
}
}
// OpenProcess("cmd.exe /c del \"" + FileFind.GetFilePath() + "\"" , 500);
}
相关文章推荐
- Win32 OpenProcess打开进程失败,返回5无权限操作
- Windows API ——OpenProcess——打开进程
- VC6.0打开程序进程和操作进程
- 【原创】进程操作:程序只能由特定进程打开,不能单独双击运行的比较笨的解决办法
- 猎豹MFC--打开进程openProcess,终止其他进程TerminateProcess
- OpenProcess打开进程返回错误的问题
- WindowsAPI详解——OpenProcess 打开|获得进程句柄 - [VC++编程]
- 打开一已存在的进程OpenProcess
- 打开,关闭 Notepad.exe 进程操作
- 记一次WinForm程序中主进程打开子进程并传递参数的操作过程(进程间传递参数)
- 关于linux中进程打开同一文件操作的一点分析
- Windows API ——OpenProcess——打开进程
- 如何查看一个进程打开哪些fd及对应的文件或套接字操作
- MFC方法OpenProcess打开一个已存在的进程对象,并返回进程的句柄
- 查看进程所用的内存(使用GetWindowThreadProcessId取得进程ID,OpenProcess打开进程和GetProcessMemoryInfo取得内存信息)
- WindowAPI 详解--OpenProcess打开获得进程句柄
- 关闭用户打开的进程处理
- 用keil2软件关闭,新建,打开一个工程的操作流程
- iOS 常用打开操作(打开网页,打电话,发邮件,发信息等)
- docker守护进程的配置和操作