RE: How do we know when Windows goes to Standby mode?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Ying-Shen Yu[MSFT] (v-yiy_at_online.microsoft.com)
Date: 03/16/04


Date: Tue, 16 Mar 2004 12:16:13 GMT

Hi,

Well, this is a different question to how to know the system status.
>From Windows 2000, there is an API SetSuspendState which enable you switch
the system into Standby or Hibernate state, for more information you may
referr to
<SetSuspendState>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/power/base/
setsuspendstate.asp

For how to shutdown/Logoff the system, you may use API
ExitWindows/ExitWindowsEx, however On windows 2000 and later system, if you
want to log off /Shut down/reboot the system, your program need get the a
special privilege before calling this API. For more information you may
referr to
<ExitWindowsEx>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/bas
e/exitwindowsex.asp
There is also a sample to show you how to shutdown the system, however it's
written in C++.

Unfortunately, these APIs is not included in current release of .NET
Framework. You need use them by P/Invoke. There is an sample project on
CodeProject.com
Maybe you can take reference from it.
<Timer Computer Shutdown>
http://www.codeproject.com/csharp/timercomputershutdown.asp

Best regards,

Ying-Shen Yu [MSFT]
Microsoft community Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, please remove the word "online"
before sending mail.



Relevant Pages

  • Re: newbe about API
    ... Emne: Re: newbe about API ... > I found all these API-CALL strings are finally compiled to ... more than that...and Windows simply takes this to an extreme that this ... DLL, when a weak point is found (which, with Microsoft, is something ...
    (alt.lang.asm)
  • Re: In the Shallow End
    ... When a document claims how an API is supposed to be used and then gives the user examples that actually work, ... Vague in your instance means you have no context to VMS or UNIX of that era. ... Windows offers lots of this stuff. ... That's why Apple had to dump a whole paradigm to plunge ahead and take the lead. ...
    (comp.sys.mac.advocacy)
  • Re: a pre-beginners question: what is the pros and cons of .net, compared to ++
    ... as the windows forms architecture wraps a number of activex ... and retains backwards compatibility with both COM and the classic Win32 api. ... C++ cannot inherently do video capture either, since you have to import COM. ... Outlook or Word or IM programs, each of which would run in managed code ...
    (microsoft.public.dotnet.general)
  • Re: Interpreting a BAS module
    ... unicode and ansi strings. ... applications make calls out to Windows to ask it to do something (e.g. ... you have to utilize an API that is designed to ... AddressOf is also used in subclassing. ...
    (microsoft.public.vb.general.discussion)
  • Re: WMF vulnerability was a deliberate backdoor?
    ... > was a deliberate backdoor put into all of Microsoft's recent editions of Windows. ... This ABORTPROC issues has been in Windows for many, ... allowed SETABORTPROC when the stream is backed solely by a *file* stream ... Whether this is a good idea or not, it's part of a published API to the ...
    (Bugtraq)