From: Karm Eastem Karm on 13 Jan 2010 06:50 Hi It is not really a kernel programming question, but it has kernel implications: I have a Win32 service that must perform WMI calls when the machine shutdowns and when the service stops. I call the same function in my OnStop and OnShutdown handlers. It works well if the service is stopped but if the machine is shutdown, my calls to WMI fails with an exception. The message is "a system Shutdown is in progress". I also got some other messages such as "Invalid request" or something similar My serivce depends on winmgmt service, but it seems that dependencies are not taken into account at shutdown. I am using Windows 7 as my test environment. I tried to open an handle on winmgmt and to close it only when I'm done, but this is useless. According to this article: http://support.microsoft.com/default.aspx/kb/203878 service dependencies are not taken into account at shutdown. It was for WinNT? 2K, XP but I guess it's still true for Vista and Win7. I could force a service stop in a shutdown script, but this is not elegant and will make my installation program a little more complex. So my question: How can I make sure that my service is sent the shutodwn notification before wimmgmt service and that winmgmt service is not sent a shutdown notification before by service completely stopped? Thanks in advance
From: Kerem Gümrükcü on 13 Jan 2010 13:22 Hi, AFAIK you cant. But you can do this to get a notification when the system is about to go down: http://msdn.microsoft.com/en-us/library/ms685058%28VS.85%29.aspx Have a look at dwControl and SERVICE_CONTROL_PRESHUTDOWN Regards Kerem -- ----------------------- Beste Grüsse / Best regards / Votre bien devoue Kerem Gümrükcü Latest Project: http://www.pro-it-education.de/software/deviceremover Latest Open-Source Projects: http://entwicklung.junetz.de ----------------------- "Karm Eastem" <Karm Eastem(a)discussions.microsoft.com> schrieb im Newsbeitrag news:7A1B0956-AD53-4788-847B-685BAFFE0FED(a)microsoft.com... > Hi > > It is not really a kernel programming question, but it has kernel > implications: > > I have a Win32 service that must perform WMI calls when the machine > shutdowns and when the service stops. > > I call the same function in my OnStop and OnShutdown handlers. > > It works well if the service is stopped but if the machine is shutdown, my > calls to WMI fails with an exception. The message is "a system Shutdown is > in > progress". I also got some other messages such as "Invalid request" or > something similar > > My serivce depends on winmgmt service, but it seems that dependencies are > not taken into account at shutdown. > > I am using Windows 7 as my test environment. > > I tried to open an handle on winmgmt and to close it only when I'm done, > but > this is useless. > > According to this article: > http://support.microsoft.com/default.aspx/kb/203878 > service dependencies are not taken into account at shutdown. It was for > WinNT? 2K, XP but I guess it's still true for Vista and Win7. > > I could force a service stop in a shutdown script, but this is not elegant > and will make my installation program a little more complex. > > So my question: > How can I make sure that my service is sent the shutodwn notification > before > wimmgmt service and that winmgmt service is not sent a shutdown > notification > before by service completely stopped? > > Thanks in advance
From: Karl Eastem Karl on 14 Jan 2010 05:30 Thanks I took a look at RegisterServiceCtrlHandlerEx and it seems like this is what I need to use to register a callback that would handle SERVICE_CONTROL_PRESHUTDOWN control code. Since I am using Delphi's TService class and it does not implement RegisterServiceCtrlHandlerEx, I'll have to write my own Service Application, but I did it in the past, I'll do it again and "backport" my current code to a "simpler" framework in which I control everything. Unless I find something strange, I think we can consider this question as "resolved" Regards - Karl "Kerem Gümrükcü" wrote: > Hi, > > AFAIK you cant. But you can do this > to get a notification when the system > is about to go down: > > http://msdn.microsoft.com/en-us/library/ms685058%28VS.85%29.aspx > Have a look at dwControl and SERVICE_CONTROL_PRESHUTDOWN > > > Regards > > Kerem > > -- > ----------------------- > Beste Grüsse / Best regards / Votre bien devoue > Kerem Gümrükcü > Latest Project: http://www.pro-it-education.de/software/deviceremover > Latest Open-Source Projects: http://entwicklung.junetz.de > -----------------------
|
Pages: 1 Prev: VDD under "New Generation" Windows Next: VirtualProtect solution |