calling (P/Invoked) exitwindows freezes my system.

  • Thread starter Thread starter Bredal Jensen
  • Start date Start date
B

Bredal Jensen

My apllication needs to shut down windows XP when users are done with it
and i have therefore p/Invoked exitwindows as suggested from this
newsgroup.(My earlier posting)




Can soeone tell me why is this freezing.


Many thanks ...
 
Bredal,

Can you show the code that you are using (the declaration and the call).

Also, it is possible that there are programs that are hung and waiting
to exit, and that is preventing the shutdown of the system.

Hope this helps.
 
What exactly do you mean with freeze, do some main windows get closed
anyway? Can you still start new applications like taskman? Did you check the
return value of ExitWindows?

Note that calling ExitWindows does not guarantee a successful shutdown. If
one of the interactive applications return false on receive of the
WM_QUERYSESSION message, the shutdown process will be aborted. If an (UI)
application fails to reply in a timely fashion a dialog will presented to
ask the user to continue that wait or abort the program.

Willy.
 
1)
using System.Runtime.InteropServices ;

......





public class Form1 : System.Windows.Forms.Form

{

[DllImport("user32.dll", SetLastError=true)]

public static extern bool ExitWindows(

[MarshalAs(UnmanagedType.U4)]

int dwReserved,

[MarshalAs(UnmanagedType.U4)]

int uReserved);

.......

......







private void exit_button_Click(object sender, System.EventArgs e)

{




ExitWindows(0,0);


}

**



I think reason should be:

SHTDN_REASON_MAJOR_APPLICATION



but C# compiler do not understand it.



2)No application is running on my system except VS.NET and outlook express..









Nicholas Paldino said:
Bredal,

Can you show the code that you are using (the declaration and the call).

Also, it is possible that there are programs that are hung and waiting
to exit, and that is preventing the shutdown of the system.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Bredal Jensen said:
My apllication needs to shut down windows XP when users are done with it
and i have therefore p/Invoked exitwindows as suggested from this
newsgroup.(My earlier posting)




Can soeone tell me why is this freezing.


Many thanks ...
 
Bredal,

If you use SHTDN_REASON_MAJOR_APPLICATION, then you should be calling
ExitWindowsEx, and passing it through there. Where do you have
SHTDN_REASON_MAJOR_APPLICATION defined?


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Bredal Jensen said:
1)
using System.Runtime.InteropServices ;

.....





public class Form1 : System.Windows.Forms.Form

{

[DllImport("user32.dll", SetLastError=true)]

public static extern bool ExitWindows(

[MarshalAs(UnmanagedType.U4)]

int dwReserved,

[MarshalAs(UnmanagedType.U4)]

int uReserved);

......

.....







private void exit_button_Click(object sender, System.EventArgs e)

{




ExitWindows(0,0);


}

**



I think reason should be:

SHTDN_REASON_MAJOR_APPLICATION



but C# compiler do not understand it.



2)No application is running on my system except VS.NET and outlook
express..









in
message news:%[email protected]...
Bredal,

Can you show the code that you are using (the declaration and the call).

Also, it is possible that there are programs that are hung and
waiting
to exit, and that is preventing the shutdown of the system.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Bredal Jensen said:
My apllication needs to shut down windows XP when users are done with
it
and i have therefore p/Invoked exitwindows as suggested from this
newsgroup.(My earlier posting)




Can soeone tell me why is this freezing.


Many thanks ...
 
good question... Nowhere

Nicholas Paldino said:
Bredal,

If you use SHTDN_REASON_MAJOR_APPLICATION, then you should be calling
ExitWindowsEx, and passing it through there. Where do you have
SHTDN_REASON_MAJOR_APPLICATION defined?


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Bredal Jensen said:
1)
using System.Runtime.InteropServices ;

.....





public class Form1 : System.Windows.Forms.Form

{

[DllImport("user32.dll", SetLastError=true)]

public static extern bool ExitWindows(

[MarshalAs(UnmanagedType.U4)]

int dwReserved,

[MarshalAs(UnmanagedType.U4)]

int uReserved);

......

.....







private void exit_button_Click(object sender, System.EventArgs e)

{




ExitWindows(0,0);


}

**



I think reason should be:

SHTDN_REASON_MAJOR_APPLICATION



but C# compiler do not understand it.



2)No application is running on my system except VS.NET and outlook
express..









in
message news:%[email protected]...
Bredal,

Can you show the code that you are using (the declaration and the call).

Also, it is possible that there are programs that are hung and
waiting
to exit, and that is preventing the shutdown of the system.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)



My apllication needs to shut down windows XP when users are done with
it
and i have therefore p/Invoked exitwindows as suggested from this
newsgroup.(My earlier posting)




Can soeone tell me why is this freezing.


Many thanks ...
 
Back
Top