473,323 Members | 1,551 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

calling (P/Invoked) exitwindows freezes my system.



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 ...

Nov 16 '05 #1
5 1575
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]
- mv*@spam.guard.caspershouse.com

"Bredal Jensen" <Br***********@mimosa.com> wrote in message
news:Os*************@tk2msftngp13.phx.gbl...


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 ...

Nov 16 '05 #2


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 [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:%2****************@TK2MSFTNGP09.phx.gbl...
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]
- mv*@spam.guard.caspershouse.com

"Bredal Jensen" <Br***********@mimosa.com> wrote in message
news:Os*************@tk2msftngp13.phx.gbl...


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 ...


Nov 16 '05 #3
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.

"Bredal Jensen" <Br***********@mimosa.com> wrote in message
news:Os*************@tk2msftngp13.phx.gbl...


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 ...

Nov 16 '05 #4
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]
- mv*@spam.guard.caspershouse.com

"Bredal Jensen" <Br***********@mimosa.com> wrote in message
news:us**************@TK2MSFTNGP14.phx.gbl...


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 [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in
message news:%2****************@TK2MSFTNGP09.phx.gbl...
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]
- mv*@spam.guard.caspershouse.com

"Bredal Jensen" <Br***********@mimosa.com> wrote in message
news:Os*************@tk2msftngp13.phx.gbl...
>
>
> 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 ...
>
>
>



Nov 16 '05 #5
good question... Nowhere

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:%2***************@tk2msftngp13.phx.gbl...
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]
- mv*@spam.guard.caspershouse.com

"Bredal Jensen" <Br***********@mimosa.com> wrote in message
news:us**************@TK2MSFTNGP14.phx.gbl...


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 [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in
message news:%2****************@TK2MSFTNGP09.phx.gbl...
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]
- mv*@spam.guard.caspershouse.com

"Bredal Jensen" <Br***********@mimosa.com> wrote in message
news:Os*************@tk2msftngp13.phx.gbl...
>
>
> 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 ...
>
>
>



Nov 16 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Erik Johnson | last post by:
Hi, I am trying to spawn a daemon type program to go off on its own and do some work (asynchoronously) from within an HTTPServer, but I am running into a problem where the web browser (actually...
4
by: Daisy | last post by:
What I want to do is this: Object1 list = (Object1)this.MyMethod(typeOf(Object1), "Object1", "string1", "string2"); and Object2 list = (Object2)this.MyMethod(typeOf(Object2), "Object2",...
6
by: Claire | last post by:
When i close a client connection by using System.Net.Sockets.TcpClient.Close() method it remains open and viewable with netstat -an. public void Disconnect() { if (myClient == null) return;...
5
by: Jack Wright | last post by:
Dear All, I have a web Application "http://localhost/Web/WebForm1.aspx" that calls a WebService from "http://localhost/webserviceapp/service1.asmx"...I have set the executionTimeout to 10 secs in...
4
by: Bernie Yaeger | last post by:
I'd like to run an external exe before returning to the calling app. For example: System.Diagnostics.Process.Start("f:\imcapps\xbuild\xbuild.exe") When I call this, the code beneath immediately...
0
by: brettjasoncohen | last post by:
When stepping through a program in the PythonWin Editor, sometimes the rest of my system becomes unresponsive, espescially the program menu items (File, Edit, ..., Help). Help! Brett
15
by: dspfun | last post by:
Hi, Is it possible to print the function name of the calling function? For example, f1() and f2() both calls f3(), in f3() I would like to print the name of the function calling f3() which...
1
by: houh | last post by:
I have a java app that generates openoffice docs. When I run the java app in a shell script, as: export JAVA_HOME=/opt/corp/projects/metrics/Java/jdk1.5.0_07/bin/java export...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.