How To Make A Shutdown Manager In C#

All tutorials created in C# to be posted in here.
1 post Page 1 of 1
Contributors
User avatar
Shim
VIP - Donator
VIP - Donator
Posts: 882
Joined: Wed Dec 14, 2011 5:02 am

How To Make A Shutdown Manager In C#
Shim
hey guys hehaho;

this is a small tutorial by the way i think this could be very useful to you all . now like we are creating shut down managers in vb.net you just need to add three buttons and change the text property as below
  1. [#]Button1 = Logoff
    [#]Button2 = Restart
    [#]Button3 = Shut Down
i should say that this program tested on windows 7 and i dont know whether this works in windows xp and windows vista also windows 8 :? thats not a problem :D .

now you need to add user32.dll to make the program work so just add this piece of code under the
Code: Select all
InitializeComponent();
        }
code -
Code: Select all
  [DllImport("user32.dll")]
        public static extern int ExitWindowsEx(int uFlags, int dwReason);
:ugeek:

now add the codes for click event for buttons as below
  • [-]Button1 =
    Code: Select all
    ExitWindowsEx(0, 0);
    [-]Button2 =
    Code: Select all
    ExitWindowsEx(2, 0);
    [-]Button3 =
    Code: Select all
    ExitWindowsEx(1, 0);
you can also use this kind of codes to do the same work

for shutdown
Code: Select all
System.Diagnostics.Process.Start("Shutdown", "-s -t 10");
for restart
Code: Select all
System.Diagnostics.Process.Start("Shutdown","-r -t 10")
for log off
Code: Select all
system.Diagnostics.Process.Start("Shutdown","-l -t 10")
8-)
now everything is done , go ahead and test it :geek:
Find my programs on Softpedia
1 post Page 1 of 1
Return to “C-Sharp Tutorials”