Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / May 2004

Tip: Looking for answers? Try searching our database.

System Shutdown from WinForm App

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Royce - 17 May 2004 01:42 GMT
Hi,

Can someone tell me how to send a System Shutdown message
from a WinForm application?

TIA,
Royce
Glenn Wilson - 17 May 2004 02:06 GMT
If you mean to shutdown the local machine or Remote machine, have a look at the WMI interfaces in the system.management classes.
AlexS - 17 May 2004 03:35 GMT
Hi, Royce

You have to use ExitWindowsEx API and here is example, which I use with
EWX_SHUTDOWN

 [DllImport("user32.dll", ExactSpelling=true, SetLastError=true) ]
 internal static extern bool ExitWindowsEx( int flag, int reason );

 public const int EWX_LOGOFF = 0x00000000;
 public const int EWX_SHUTDOWN = 0x00000001;
 public const int EWX_REBOOT = 0x00000002;
 public const int EWX_FORCE = 0x00000004;
 public const int EWX_POWEROFF = 0x00000008;
 public const int EWX_FORCEIFHUNG = 0x00000010;

 {
       flg=EWX_SHUTDOWN;
       ExitWindowsEx( flg, 0 );
 }

HTH
Alex

> Hi,
>
[quoted text clipped - 3 lines]
> TIA,
> Royce
Gabriele G. Ponti - 17 May 2004 13:11 GMT
This is not going to work properly on NT/2000/XP as they require the
application to have a specific privilege.

http://www.dotnet247.com/247reference/msgs/3/17306.aspx

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.