Thread: difference when starting a program from network?

  1. #1
    Registered User
    Join Date
    Jan 2007
    Posts
    330

    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.

    Code:
            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)
                {
                    return;
                }
    
                base.WndProc(ref m);
            }
    
            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
    }
    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.

    What could be the problem here when started from the network?

  2. #2
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    .NET programs started from a network drive are considered insecure and run with lower privileges. Normally, you get an error message when you try to do something that is forbidden, but maybe this is somehow different.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Starting to program
    By Charmees in forum C++ Programming
    Replies: 3
    Last Post: 07-22-2008, 02:25 PM
  2. Starting a program
    By mcgeady in forum C++ Programming
    Replies: 3
    Last Post: 02-25-2006, 12:52 PM
  3. starting program
    By Ideswa in forum C++ Programming
    Replies: 3
    Last Post: 02-20-2006, 02:36 PM
  4. Starting a Program, use C or C++?
    By firestorm in forum Windows Programming
    Replies: 12
    Last Post: 04-11-2005, 09:07 PM
  5. Starting the program
    By vasanth in forum C++ Programming
    Replies: 2
    Last Post: 02-28-2002, 04:51 AM