How do I detect a system shutdown?

All I want to do is detect that the system is shutting down in my driver
so I can write something (save settings) to the registry. I have tried
these methods:

  1. Assumed XP unloaded my driver before shutting down… I assumed
    wrong.
  2. Looked for a system power state change via IRP_MN_SET_POWER with
    PowerType==SystemPowerState and PowerState==PowerSystemShutdown as the
    data. Didn’t seem to get the Irp.
  3. Tried to register for shutdown notification with
    IoRegisterShutdownNotification()… Couldn’t link. Still dont know what
    lib it is in. Also, does not appear to be compatible with Win98.

Please help me before I go completely insane. :slight_smile:

-Justin

can’t you use IRP_MJ_SHUTDOWN ?

Else

“Justin Frodsham”
To: “NT Developers Interest List”
Sent by: cc:
xxxxx@lis Subject: [ntdev] How do I detect a system shutdown?
ts.osr.com

11.10.2002 05:17
Please respond to “NT
Developers Interest
List”

All I want to do is detect that the system is shutting down in my driver
so I can write something (save settings) to the registry. I have tried
these methods:

1. Assumed XP unloaded my driver before shutting down… I assumed
wrong.
2. Looked for a system power state change via IRP_MN_SET_POWER with
PowerType==SystemPowerState and PowerState==PowerSystemShutdown as the
data. Didn’t seem to get the Irp.
3. Tried to register for shutdown notification with
IoRegisterShutdownNotification()… Couldn’t link. Still dont know what
lib it is in. Also, does not appear to be compatible with Win98.

Please help me before I go completely insane. :slight_smile:

-Justin


You are currently subscribed to ntdev as: xxxxx@utimaco.de
To unsubscribe send a blank email to %%email.unsub%%

You will go insane if you try to do something for NT & 98. 2K & XP have Power state change callback you can register for.

“Justin Frodsham” wrote in message news:xxxxx@ntdev…
>
> All I want to do is detect that the system is shutting down in my driver
> so I can write something (save settings) to the registry. I have tried
> these methods:
>
> 1. Assumed XP unloaded my driver before shutting down… I assumed
> wrong.
> 2. Looked for a system power state change via IRP_MN_SET_POWER with
> PowerType==SystemPowerState and PowerState==PowerSystemShutdown as the
> data. Didn’t seem to get the Irp.
> 3. Tried to register for shutdown notification with
> IoRegisterShutdownNotification()… Couldn’t link. Still dont know what
> lib it is in. Also, does not appear to be compatible with Win98.
>
> Please help me before I go completely insane. :slight_smile:
>
> -Justin
>
>

I listed that as option number 3, like I said, I cant get it to link and it
does not appear to be compatible with the 98 ddk.

-Justin

At 12:32 AM 10/11/2002, you wrote:

can’t you use IRP_MJ_SHUTDOWN ?

Else

“Justin
Frodsham”

To: “NT Developers
> Interest List”
> Sent
> by: cc:
>
> xxxxx@lis Subject: [ntdev] How
> do I detect a system shutdown?
> ts.osr.com
>
>
>
>
>
> 11.10.2002
> 05:17
>
> Please respond to
> “NT
>
> Developers
> Interest
>
> List”
>
>
>
>
>
>
>
>
>
>All I want to do is detect that the system is shutting down in my driver
>so I can write something (save settings) to the registry. I have tried
>these methods:
>
>1. Assumed XP unloaded my driver before shutting down… I assumed
>wrong.
>2. Looked for a system power state change via IRP_MN_SET_POWER with
>PowerType==SystemPowerState and PowerState==PowerSystemShutdown as the
>data. Didn’t seem to get the Irp.
>3. Tried to register for shutdown notification with
>IoRegisterShutdownNotification()… Couldn’t link. Still dont know what
>lib it is in. Also, does not appear to be compatible with Win98.
>
>Please help me before I go completely insane. :slight_smile:
>
>-Justin
>
>—
>You are currently subscribed to ntdev as: xxxxx@utimaco.de
>To unsubscribe send a blank email to %%email.unsub%%
>
>
>
>
>
>—
>You are currently subscribed to ntdev as: zeppelin@io.com
>To unsubscribe send a blank email to %%email.unsub%%

I did read somewhere about register for a callback. Is that the only
way? There is no 98 solution?

-Justin

At 03:43 AM 10/11/2002, you wrote:

You will go insane if you try to do something for NT & 98. 2K & XP have
Power state change callback you can register for.

“Justin Frodsham” wrote in message news:xxxxx@ntdev…
> >
> > All I want to do is detect that the system is shutting down in my driver
> > so I can write something (save settings) to the registry. I have tried
> > these methods:
> >
> > 1. Assumed XP unloaded my driver before shutting down… I assumed
> > wrong.
> > 2. Looked for a system power state change via IRP_MN_SET_POWER with
> > PowerType==SystemPowerState and PowerState==PowerSystemShutdown as the
> > data. Didn’t seem to get the Irp.
> > 3. Tried to register for shutdown notification with
> > IoRegisterShutdownNotification()… Couldn’t link. Still dont know what
> > lib it is in. Also, does not appear to be compatible with Win98.
> >
> > Please help me before I go completely insane. :slight_smile:
> >
> > -Justin
> >
> >
>
>—
>You are currently subscribed to ntdev as: zeppelin@io.com
>To unsubscribe send a blank email to %%email.unsub%%

I am not sure why #2 & #3 are not working for you. I do get power state changes and callbacks. The thing you have be aware of is that even if you get power state changes indicating a shutdown, the registry may not be in a state where you can write to it.

I link IoRegisterShutdownNotification just fine in Win98. Just make sure define it properly like

NTKERNELAPI NTSTATUS IoRegisterShutdownNotification(IN PDEVICE_OBJECT DeviceObject);

“Justin Frodsham” wrote in message news:xxxxx@ntdev…
>
> I did read somewhere about register for a callback. Is that the only
> way? There is no 98 solution?
>
> -Justin
>
> At 03:43 AM 10/11/2002, you wrote:
> >You will go insane if you try to do something for NT & 98. 2K & XP have
> >Power state change callback you can register for.
> >
> >“Justin Frodsham” wrote in message news:xxxxx@ntdev…
> > >
> > > All I want to do is detect that the system is shutting down in my driver
> > > so I can write something (save settings) to the registry. I have tried
> > > these methods:
> > >
> > > 1. Assumed XP unloaded my driver before shutting down… I assumed
> > > wrong.
> > > 2. Looked for a system power state change via IRP_MN_SET_POWER with
> > > PowerType==SystemPowerState and PowerState==PowerSystemShutdown as the
> > > data. Didn’t seem to get the Irp.
> > > 3. Tried to register for shutdown notification with
> > > IoRegisterShutdownNotification()… Couldn’t link. Still dont know what
> > > lib it is in. Also, does not appear to be compatible with Win98.
> > >
> > > Please help me before I go completely insane. :slight_smile:
> > >
> > > -Justin
> > >
> > >
> >
> >—
> >You are currently subscribed to ntdev as: zeppelin@io.com
> >To unsubscribe send a blank email to %%email.unsub%%
>
>
>
>
>

Wow am I a dummy. Can someone give me a virtual boot to the head
please. Since I don’t include ntddk.h ( i use wdm.h), I had to forward
declare the register function myself. However, I forgot to use extern “C”
in front of it… Doh! As far as option 2, I am going to try a
different machine as my laptop (never buy an HP laptop, they blow) has
been exhibiting a couple other problems… like not actually putting my
usb device into D3 on idle detect (works just fine on other computers).

Thanks,
Justin

At 09:31 AM 10/11/2002, you wrote:

I am not sure why #2 & #3 are not working for you. I do get power state
changes and callbacks. The thing you have be aware of is that even if you
get power state changes indicating a shutdown, the registry may not be in
a state where you can write to it.

I link IoRegisterShutdownNotification just fine in Win98. Just make sure
define it properly like

NTKERNELAPI NTSTATUS IoRegisterShutdownNotification(IN PDEVICE_OBJECT
DeviceObject);

“Justin Frodsham” wrote in message news:xxxxx@ntdev…
> >
> > I did read somewhere about register for a callback. Is that the only
> > way? There is no 98 solution?
> >
> > -Justin
> >
> > At 03:43 AM 10/11/2002, you wrote:
> > >You will go insane if you try to do something for NT & 98. 2K & XP have
> > >Power state change callback you can register for.
> > >
> > >“Justin Frodsham” wrote in message news:xxxxx@ntdev…
> > > >
> > > > All I want to do is detect that the system is shutting down in my
> driver
> > > > so I can write something (save settings) to the registry. I have tried
> > > > these methods:
> > > >
> > > > 1. Assumed XP unloaded my driver before shutting down… I assumed
> > > > wrong.
> > > > 2. Looked for a system power state change via IRP_MN_SET_POWER with
> > > > PowerType==SystemPowerState and PowerState==PowerSystemShutdown as the
> > > > data. Didn’t seem to get the Irp.
> > > > 3. Tried to register for shutdown notification with
> > > > IoRegisterShutdownNotification()… Couldn’t link. Still dont
> know what
> > > > lib it is in. Also, does not appear to be compatible with Win98.
> > > >
> > > > Please help me before I go completely insane. :slight_smile:
> > > >
> > > > -Justin
> > > >
> > > >
> > >
> > >—
> > >You are currently subscribed to ntdev as: zeppelin@io.com
> > >To unsubscribe send a blank email to %%email.unsub%%
> >
> >
> >
> >
> >
>
>—
>You are currently subscribed to ntdev as: zeppelin@io.com
>To unsubscribe send a blank email to %%email.unsub%%