启动一个进程,并让他等待接收消息
2008-05-13 10:19
507 查看
// Start the child process.
if( !CreateProcess( NULL, // No module name (use command line).
_T("explorer.exe"), // Command line.
NULL, // Process handle not inheritable.
NULL, // Thread handle not inheritable.
FALSE, // Set handle inheritance to FALSE.
0, // No creation flags.
NULL, // Use parent's environment block.
NULL, // Use parent's starting directory.
&si, // Pointer to STARTUPINFO structure.
&pi ) // Pointer to PROCESS_INFORMATION structure.
)
//wait a gracefully time
//so the window is created and is ready to answer messages.
::WaitForInputIdle(pi.hProcess,1000);
//m_hExplorerProcess=(DWORD)pi.hProcess;
//oops, this won't work
//if another explorer.exe instance exists
//the new process quits before EnumWindows
//::EnumWindows(EnumWindowsProc,(LPARAM)this);
// Close process and thread handles.
if( !CreateProcess( NULL, // No module name (use command line).
_T("explorer.exe"), // Command line.
NULL, // Process handle not inheritable.
NULL, // Thread handle not inheritable.
FALSE, // Set handle inheritance to FALSE.
0, // No creation flags.
NULL, // Use parent's environment block.
NULL, // Use parent's starting directory.
&si, // Pointer to STARTUPINFO structure.
&pi ) // Pointer to PROCESS_INFORMATION structure.
)
//wait a gracefully time
//so the window is created and is ready to answer messages.
::WaitForInputIdle(pi.hProcess,1000);
//m_hExplorerProcess=(DWORD)pi.hProcess;
//oops, this won't work
//if another explorer.exe instance exists
//the new process quits before EnumWindows
//::EnumWindows(EnumWindowsProc,(LPARAM)this);
// Close process and thread handles.
相关文章推荐
- 我在delphi中用shellExecute启动了一个程序(ftp);然后想做一个等待,只到ftp进程结束,再继续下面的操作,请问如何监控这个进程是否已结束?
- c# 关于启动一个等待MASK窗体盖住主窗体,任务完成后,关掉MASK窗体的总结
- C#TCPClient应用-一个简单的消息发送和接收
- msgrcv,msgsnd进程通信,消息的发送和接收
- android N进程启动流程(二)(上一个activity的暂停、进程启动、绑定进程与创建application)
- 安卓开发,一个Activity启动了一个本地服务,然后把Activity切换到后台,那这是后台进程还是次要服务进程
- Spring ActiveMQ 整合(一): 一个简单的demo,测试消息的发送与接收
- 异常信息:CLR无法从COM 上下文0x645e18 转换为COM上下文0x645f88,这种状态已持续60秒。拥有目标上下文/单元的线程很有可能执行的是非泵式等待或者在不发送 Windows 消息的情况下处理一个运行时间非常长的操作.这种情况通常会影响到
- Vc 如何启动一个进程
- 启动一个进程并处理进程结束事件
- 等待一个已存在的进程
- C#程序多用户只启动一个进程的方法
- Linux:如何查看一个进程的详细的启动时间
- TNS/ORA-12500:TNS:监听未能启动一个专用服务器进程
- 第一个(应用的)组件启动时,(系统)创建主进程(包名)+主线程,Application对象 (一个应用所有组件默认运行在同一个进程)
- c#的Process启动另一个进程作为程序的一个界面
- 在一个进程中启动另一个进程---CreateProcess API
- startActivity -进程不在->创建进程->ActivityThread.main->启动主线程消息循环
- c#启动一个计算器进程
- 等待一个进程结束,调用外部exe