Click here to Skip to main content
15,910,981 members
Home / Discussions / C#
   

C#

 
GeneralRe: Correct way to reset the modem Pin
Heath Stewart5-Aug-04 3:09
protectorHeath Stewart5-Aug-04 3:09 
GeneralRe: Correct way to reset the modem Pin
Serge Lobko-Lobanovsky5-Aug-04 3:17
Serge Lobko-Lobanovsky5-Aug-04 3:17 
GeneralRe: Correct way to reset the modem Pin
Heath Stewart5-Aug-04 3:24
protectorHeath Stewart5-Aug-04 3:24 
GeneralRe: Correct way to reset the modem Pin
Squeaker5-Aug-04 7:24
Squeaker5-Aug-04 7:24 
Questionis it possible to forcE thumbnail view in open dialog? Pin
misterbear5-Aug-04 1:33
misterbear5-Aug-04 1:33 
QuestionWhich richTextBox Event to use ? Pin
evdoxos5-Aug-04 1:16
evdoxos5-Aug-04 1:16 
AnswerRe: Which richTextBox Event to use ? Pin
Heath Stewart5-Aug-04 2:55
protectorHeath Stewart5-Aug-04 2:55 
GeneralRe: Which richTextBox Event to use ? Pin
evdoxos5-Aug-04 3:09
evdoxos5-Aug-04 3:09 
GeneralRe: Which richTextBox Event to use ? Pin
Heath Stewart5-Aug-04 3:14
protectorHeath Stewart5-Aug-04 3:14 
GeneralRe: Which richTextBox Event to use ? Pin
evdoxos5-Aug-04 3:24
evdoxos5-Aug-04 3:24 
QuestionProbably Reflection... but how? Pin
matthias s.5-Aug-04 1:05
matthias s.5-Aug-04 1:05 
AnswerRe: Probably Reflection... but how? Pin
Heath Stewart5-Aug-04 2:47
protectorHeath Stewart5-Aug-04 2:47 
GeneralRe: Probably Reflection... but how? Pin
matthias s.5-Aug-04 3:26
matthias s.5-Aug-04 3:26 
GeneralRe: Probably Reflection... but how? Pin
Heath Stewart5-Aug-04 3:35
protectorHeath Stewart5-Aug-04 3:35 
Generalget opened folder in Outlook Pin
Stephan Wright5-Aug-04 0:36
Stephan Wright5-Aug-04 0:36 
GeneralRe: get opened folder in Outlook Pin
Michael P Butler5-Aug-04 4:09
Michael P Butler5-Aug-04 4:09 
GeneralRe: get opened folder in Outlook Pin
Stephan Wright5-Aug-04 22:46
Stephan Wright5-Aug-04 22:46 
GeneralRe: get opened folder in Outlook Pin
Michael P Butler5-Aug-04 22:51
Michael P Butler5-Aug-04 22:51 
GeneralRe: get opened folder in Outlook Pin
Stephan Wright5-Aug-04 23:01
Stephan Wright5-Aug-04 23:01 
GeneralRe: get opened folder in Outlook Pin
Michael P Butler5-Aug-04 23:17
Michael P Butler5-Aug-04 23:17 
Generaldisable poweroff function Pin
JockerSoft4-Aug-04 22:57
JockerSoft4-Aug-04 22:57 
GeneralRe: disable poweroff function Pin
leppie5-Aug-04 0:45
leppie5-Aug-04 0:45 
GeneralRe: disable poweroff function Pin
Heath Stewart5-Aug-04 1:46
protectorHeath Stewart5-Aug-04 1:46 
GeneralRe: disable poweroff function Pin
Heath Stewart5-Aug-04 2:24
protectorHeath Stewart5-Aug-04 2:24 
The SPI_SETPOWEROFFACTIVE may have more to do with the system suspension state than the monitor. The documentation is a little vague on this matter.

I did try a few things. Handling the WM_POWERBROADCAST message with the PBT_APMQUERYSUSPEND only seems to work with the power state, so the next logical choice is something like this:

P/Invoke both GetActivePwrScheme and SetActivePwrScheme, as well as declare the POWER_SCHEME structure (you can flatten it if you like, since unmanaged structures are just blocks of contiguous memory). Information about these functions and this struct can be found in the Platform SDK at http://msdn.microsoft.com/library[^]. You can pass null (or IntPtr.Zero) to the second parameter (declare it as an IntPtr in order to pass IntPtr.Zero). If you do so, the signature would look like this:
[DllImport("powrprof.dll")]
static extern bool SetActivePwrSchema(uint id, IntPtr globalPolicy,
  ref POWER_POLICY powerPolicy);
First call GetActivePwrScheme to get an ID for the current policy. Change the POWER_POLICY.user.VideoTimeoutAc (typed as it's named in the Platform SDK) to either 0 or UInt32.MaxValue (not sure which) to set the power state of the monitor to off or a relatively indefinite time (far more than the life of a computer), whichever works (such values aren't documented).

Don't forget to clean-up your code, however, like storing the previous VideoTimeoutAc value and doing this over with the previous value. This will merge the previous state with the new state, but there's nothing I see in the documentation that dictates whether that merged state is persisted in the power scheme or if its just for the duration of the computer's up-time (still always a good idea to undo what you've done, though).

 

Microsoft MVP, Visual C#
My Articles
GeneralRe: disable poweroff function Pin
Dave Kreskowiak5-Aug-04 8:10
mveDave Kreskowiak5-Aug-04 8:10 

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.