difference when starting a program from network?
the following code prevents windows from letting the monitor go into sleep mode when the program is active and wakes the monitor up after a scanner scans something.
when the program is started normally it works fine. But when the program is started from a network share it goes to sleep anyway and the OnScan does not work anymore. Removing the SendMessage line makes OnScan work again but then the monitor wont wake up on a scan of course.
protected override void WndProc(ref Message m)
if (m.Msg == W32.Const.WM_SYSCOMMAND &&
(m.WParam.ToInt32() & 0xfff0) == W32.Const.SC_MONITORPOWER && m.LParam.ToInt32() != -1)
public void OnScan(string line)
this.Activate(); // activate the window on every scan
W32.Funcs.SendMessage(Handle, W32.Const.WM_SYSCOMMAND, (IntPtr)W32.Const.SC_MONITORPOWER, (IntPtr)(-1)); // wake up the monitor
What could be the problem here when started from the network?