博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
WaitForInputIdle 的注意细节
阅读量:7154 次
发布时间:2019-06-29

本文共 2138 字,大约阅读时间需要 7 分钟。

  MSDN上如此说:

  The WaitForInputIdle function waits until the specified process is waiting for user input with no input pending, or until the time-out interval has elapsed.
  DWORD WaitForInputIdle( HANDLE hProcess, // handle to process
         DWORD dwMilliseconds // time-out interval
      );

  Parameters
hProcess
  
[in] Handle to the process. If this process is a console application or does not have a message queue,
WaitForInputIdle returns immediately.
dwMilliseconds
  
[in] Specifies the time-out interval, in milliseconds. If
dwMilliseconds is INFINITE, the function does not return until the process is idle.

  Return Values

  The following table shows the possible return values:

Value Meaning
0 The wait was satisfied successfully.
WAIT_TIMEOUT The wait was terminated because the time-out interval elapsed.
-1 An error occurred. To get extended error information, use the GetLastError function.

  Remarks

  The WaitForInputIdle function enables a thread to suspend its execution until the specified process has finished its initialization and is waiting for user input with no input pending. This can be useful for synchronizing a parent process and a newly created child process. When a parent process creates a child process, the CreateProcess function returns without waiting for the child process to finish its initialization. Before trying to communicate with the child process, the parent process can use WaitForInputIdle to determine when the child's initialization has been completed. For example, the parent process should use WaitForInputIdle before trying to find a window associated with the child process.

The WaitForInputIdle function can be used at any time, not just during application startup.

Requirements

Windows NT/2000: Requires Windows NT 3.1 or later.

Windows 95/98: Requires Windows 95 or later.
Header: Declared in Winuser.h; include Windows.h.
Library: Use User32.lib.

 

  补充:我觉得这个函数在CreateProcess之后只是为新进程初始化进程代码然后就返回,并不是等进程完全创建好在返回。这一点大家可以用有界面的程序来测试,因为有界面的程序在代码初始化完成之后还要做一些其他事情然后再显示出界面的,所以创建有界面的程序显示界面是WaitForInputIdle已经返回了。如有不对,请指教。

转载于:https://www.cnblogs.com/ziwuge/archive/2011/12/03/2272868.html

你可能感兴趣的文章
@validated 验证 List 参数在spring中
查看>>
Tire树
查看>>
how to install oracle jdk 7 on ubuntu lucid lts 10.04
查看>>
install 7z support for ubuntu
查看>>
利用kettle中的JS来完成ETL数据校验
查看>>
Python自然语言处理学习笔记(18):3.2 字符串:最底层的文本处理
查看>>
quartz和spring结合后的使用,模仿型
查看>>
关于The status code returned from the server was: 500的错误
查看>>
POJ 3225 Help with Intervals
查看>>
e-企业管理解决方案-客户管理系统
查看>>
Windows Vista/Windows 7上安装wince5.0/6.0及SDK模拟器
查看>>
安卓应用玩换肤.半透明图片的应用
查看>>
【推荐】iOS集合视图的可重新排序的layout
查看>>
【Lucene】Apache Lucene全文检索引擎架构之搜索功能3
查看>>
算法笔记_145:拓扑排序的应用(Java)
查看>>
python 页面信息抓取
查看>>
Unity UGUI 的RectTransform参数的设置
查看>>
删除重复图片
查看>>
C# 实现PNG文件的背景透明显示,解决动态显示闪烁问题 【转】
查看>>
mysql优化——show processlist命令详解
查看>>