command line - How to find out if Windows installer is busy or not using delphi? -
i have windows service restarts windows in specific events have problem it. don't want restart windows when installing programs using windows installer.
so how can fine out whether windows installer busy installing or not.
any delphi or command line function acceptable.
will please me ?
i found these 2 classess don't know how use them.
based on this article
, quite outdated i've tried implement both suggested options. second 1 worked me on windows 7 sp1. principle query msiserver
service status , check, if service running , accepts service_accept_stop
control code. here's function wrapper that:
uses winsvc; function iswindowsinstallerbusy: boolean; var service: sc_handle; servicemgr: sc_handle; servicestatus: service_status; begin result := false; servicemgr := openscmanager(nil, nil, sc_manager_connect); if servicemgr <> 0 try service := openservice(servicemgr, 'msiserver', service_query_status); if service <> 0 try if queryservicestatus(service, servicestatus) begin result := (servicestatus.dwcurrentstate = service_running) , ((servicestatus.dwcontrolsaccepted , service_accept_stop) = 0); end else raise exception.createfmt('cannot query service status. code: %d', [getlasterror]); closeservicehandle(service); end else raise exception.createfmt('cannot open service. code: %d', [getlasterror]); closeservicehandle(servicemgr); end else raise exception.createfmt('cannot connect service control ' + 'manager. code: %d', [getlasterror]); end;
Comments
Post a Comment