问题
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