Click here to Skip to main content
15,890,512 members
Home / Discussions / C#
   

C#

 
GeneralRe: switch off computer Pin
User 665826-Jan-09 6:00
User 665826-Jan-09 6:00 
GeneralRe: switch off computer Pin
likefood26-Jan-09 6:35
likefood26-Jan-09 6:35 
GeneralRe: switch off computer Pin
likefood26-Jan-09 6:35
likefood26-Jan-09 6:35 
AnswerRe: switch off computer Pin
Giorgi Dalakishvili26-Jan-09 6:10
mentorGiorgi Dalakishvili26-Jan-09 6:10 
GeneralRe: switch off computer Pin
likefood26-Jan-09 6:36
likefood26-Jan-09 6:36 
QuestionRe: switch off computer Pin
likefood26-Jan-09 8:16
likefood26-Jan-09 8:16 
AnswerRe: switch off computer Pin
likefood26-Jan-09 8:25
likefood26-Jan-09 8:25 
AnswerRe: switch off computer Pin
Xmen Real 26-Jan-09 14:03
professional Xmen Real 26-Jan-09 14:03 
yes shutdown sucks with shutdown.exe, specially in older windows version eg. XP

here is the code i use to shut my pc down Wink | ;)

//using System.Management;
        void Shutdown()
        {
            ManagementClass W32_OS = new ManagementClass("Win32_OperatingSystem");
            ManagementBaseObject inParams, outParams;
            int result;
            W32_OS.Scope.Options.EnablePrivileges = true;
            foreach (ManagementObject obj in W32_OS.GetInstances())
            {
                inParams = obj.GetMethodParameters("Win32Shutdown");
                inParams["Flags"] = ShutDown.ForcedShutdown;
                inParams["Reserved"] = 0;
                outParams = obj.InvokeMethod("Win32Shutdown", inParams, null);
                result = Convert.ToInt32(outParams["returnValue"]);
                if (result != 0) throw new Win32Exception(result);
            }
        }
        public enum ShutDown
        {
            LogOff = 0,
            Shutdown = 1,
            Reboot = 2,
            ForcedLogOff = 4,
            ForcedShutdown = 5,
            ForcedReboot = 6,
            PowerOff = 8,
            ForcedPowerOff = 12
        }


When you test this, save all your work. There is no way to stop this thing.

TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i’TV.C\y<pŠjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can

GeneralRe: switch off computer Pin
likefood27-Jan-09 15:58
likefood27-Jan-09 15:58 
QuestionLinq to SQL question Pin
PaulPrice26-Jan-09 5:21
PaulPrice26-Jan-09 5:21 
AnswerRe: Linq to SQL question Pin
Wendelius26-Jan-09 9:00
mentorWendelius26-Jan-09 9:00 
QuestionHow to have access the drivers and API? Pin
Alex_xso26-Jan-09 5:16
Alex_xso26-Jan-09 5:16 
AnswerRe: How to have access the drivers and API? Pin
EliottA26-Jan-09 5:32
EliottA26-Jan-09 5:32 
GeneralRe: How to have access the drivers and API? Pin
WebMaster26-Jan-09 5:45
WebMaster26-Jan-09 5:45 
QuestionEmpty cell in gridview Pin
Raskelmos26-Jan-09 4:51
Raskelmos26-Jan-09 4:51 
AnswerRe: Empty cell in gridview Pin
Jim (SS)26-Jan-09 11:35
Jim (SS)26-Jan-09 11:35 
QuestionParsing Log Files Pin
alwaysthinking26-Jan-09 4:24
alwaysthinking26-Jan-09 4:24 
AnswerRe: Parsing Log Files Pin
Manas Bhardwaj26-Jan-09 4:29
professionalManas Bhardwaj26-Jan-09 4:29 
AnswerRe: Parsing Log Files Pin
Mustafa Ismail Mustafa26-Jan-09 4:41
Mustafa Ismail Mustafa26-Jan-09 4:41 
GeneralRe: Parsing Log Files Pin
alwaysthinking26-Jan-09 4:59
alwaysthinking26-Jan-09 4:59 
GeneralRe: Parsing Log Files Pin
Mark Churchill26-Jan-09 14:44
Mark Churchill26-Jan-09 14:44 
GeneralRe: Parsing Log Files Pin
Mustafa Ismail Mustafa26-Jan-09 23:49
Mustafa Ismail Mustafa26-Jan-09 23:49 
Question[Message Deleted] Pin
hkjghkj126-Jan-09 3:34
hkjghkj126-Jan-09 3:34 
AnswerRe: CopyFromScreen() question. Pin
PIEBALDconsult26-Jan-09 5:20
mvePIEBALDconsult26-Jan-09 5:20 
General[Message Deleted] Pin
hkjghkj126-Jan-09 6:50
hkjghkj126-Jan-09 6:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.