How to check if Windows is busy by installing any driver?

一笑奈何 提交于 2019-12-11 03:16:06

问题


I write program which installs usb device driver by means of dpinst.exe. At program start I want to check if Windows is busy by searching/installing/updating some driver. (Main scenario I want to avoid is launch of dpinst.exe while Windows is searching driver for plugged device.) How can I check that?


回答1:


Solution is to use CMP_WaitNoPendingInstallEvents function. Example here.




回答2:


You can use Process to look if another instance of dpinst is already running.

Process[] processlist = Process.GetProcesses();

foreach(Process p in processlist){
    if (p.ProcessName.StartsWith("dpinst"))
      ...
}

I would bet that this is unnecessary : the scenario you are trying to avoid is already being managed by dpinst/Windows itself.



来源:https://stackoverflow.com/questions/23925594/how-to-check-if-windows-is-busy-by-installing-any-driver

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!