|
e fai amano no? ....il programma diko...
Monitor Power Off III: the solution !
Success! Small change, big consequences. The Desktop window seems not able to process the message, but the TopMost window (HWND -1) is!
The code below works on SP2 (and probably on any system).
using System;using System.Runtime.InteropServices;
namespace TestApp{ class Class1 { [DllImport("user32.dll", SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] static extern bool PostMessage(IntPtr hWnd, UInt32 Msg, int wParam, int lParam);
[STAThread] static void Main(string[] args) { const int MONITOR_ON = -1; const int MONITOR_OFF = 2; const int WM_SYSCOMMAND = 0x0112; const int SC_MONITORPOWER = 0xF170; const int HWND_TOPMOST = -1;
System.Threading.Thread.Sleep(2000);
PostMessage(HWND_TOPMOST, WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_OFF);
System.Threading.Thread.Sleep(2000); } }}
A quanto vedo è un problema drammatiko e molto sentito sulla rete....
__________________
Il segreto dell'uomo politico è rendersi stupido come i suoi ascoltatori facendogli credere di essere intelligenti come lui.
|