示例#1
0
        // Overloaded constructor that accepts a reference to the
        // Messages object created by the form.
        public PowerNotifications(ref Messages mList)
        {
            // assign the messages object
            MessageList = mList;

            // set up the Message queue options, create the queue
            // and create a background thread to monitor it
            MsgQOptions options = new MsgQOptions();

            options.dwFlags       = 0;
            options.dwMaxMessages = 20;
            options.cbMaxMessage  = 10000;
            options.bReadAccess   = true;
            options.dwSize        = (uint)System.Runtime.InteropServices.Marshal.SizeOf(options);
            ptr = CreateMsgQueue("Test", ref options);
            IntPtr ptr2 = RequestPowerNotifications(ptr, 0xFFFFFFFF);

            if (ptr2.Equals(IntPtr.Zero))
            {
                // error occurred
                MessageList.AddMessage("Error with RPN");
            }

            t = new Thread(new ThreadStart(DoWork));
        }
 public PowerNotifications()
 {
     MsgQOptions options = new MsgQOptions();
     options.dwFlags = 0;
     options.dwMaxMessages = 20;
     options.cbMaxMessage = 10000;
     options.bReadAccess = true;
     options.dwSize = (uint)System.Runtime.InteropServices.Marshal.SizeOf(options);
     ptr = CreateMsgQueue("Test", ref options);
     RequestPowerNotifications(ptr, 0xFFFFFFFF);
     t = new Thread(new ThreadStart(DoWork));
 }
        public PowerNotifications()
        {
            MsgQOptions options = new MsgQOptions();

            options.dwFlags       = 0;
            options.dwMaxMessages = 20;
            options.cbMaxMessage  = 10000;
            options.bReadAccess   = true;
            options.dwSize        = (uint)System.Runtime.InteropServices.Marshal.SizeOf(options);
            ptr = CreateMsgQueue("Test", ref options);
            RequestPowerNotifications(ptr, 0xFFFFFFFF);
            t = new Thread(new ThreadStart(DoWork));
        }
示例#4
0
        public PowerNotifications()
        {
            MsgQOptions options = new MsgQOptions();

            options.dwFlags       = 0;
            options.dwMaxMessages = 20;
            options.cbMaxMessage  = 10000;
            options.bReadAccess   = true;
            options.dwSize        = (uint)Marshal.SizeOf(options);
            ptr = CreateMsgQueue("Test", ref options);
            RequestPowerNotifications(ptr, POWER_NOTIFY_ALL);
            t      = new Thread(DoWork);
            t.Name = "Power events listening thread";
        }
示例#5
0
        public PowerNotifications()
        {
            // set up the Message queue options, create the queue
            // and create a background thread to monitor it
            MsgQOptions options = new MsgQOptions();

            options.dwFlags       = 0;
            options.dwMaxMessages = 20;
            options.cbMaxMessage  = 10000;
            options.bReadAccess   = true;
            options.dwSize        = (uint)System.Runtime.InteropServices.Marshal.SizeOf(options);
            ptr = CreateMsgQueue("Test", ref options);
            RequestPowerNotifications(ptr, 0xFFFFFFFF);
            t = new Thread(new ThreadStart(DoWork));
        }
 private static extern IntPtr CreateMsgQueue(string name, ref MsgQOptions options);
示例#7
0
 private static extern IntPtr CreateMsgQueue(string name, ref MsgQOptions options);
 public PowerNotifications()
 {
     MsgQOptions options = new MsgQOptions();
     options.dwFlags = 0;
     options.dwMaxMessages = 20;
     options.cbMaxMessage = 10000;
     options.bReadAccess = true;
     options.dwSize = (uint)Marshal.SizeOf(options);
     ptr = CreateMsgQueue("Test", ref options);
     RequestPowerNotifications(ptr, POWER_NOTIFY_ALL);
     t = new Thread(DoWork);
     t.Name = "Power events listening thread";
 }
示例#9
0
        // Overloaded constructor that accepts a reference to the
        // Messages object created by the form.
        public PowerNotifications(ref Messages mList)
        {
            // assign the messages object
            MessageList = mList;

            // set up the Message queue options, create the queue
            // and create a background thread to monitor it
            MsgQOptions options = new MsgQOptions();
            options.dwFlags = 0;
            options.dwMaxMessages = 20;
            options.cbMaxMessage = 10000;
            options.bReadAccess = true;
            options.dwSize = (uint)System.Runtime.InteropServices.Marshal.SizeOf(options);
            ptr = CreateMsgQueue("Test", ref options);
            IntPtr ptr2 = RequestPowerNotifications(ptr, 0xFFFFFFFF);
            if (ptr2.Equals(IntPtr.Zero))
            {
                // error occurred
                MessageList.AddMessage("Error with RPN");
            }

            t = new Thread(new ThreadStart(DoWork));
        }
示例#10
0
 public PowerNotifications()
 {
     // set up the Message queue options, create the queue
     // and create a background thread to monitor it
     MsgQOptions options = new MsgQOptions();
     options.dwFlags = 0;
     options.dwMaxMessages = 20;
     options.cbMaxMessage = 10000;
     options.bReadAccess = true;
     options.dwSize = (uint)System.Runtime.InteropServices.Marshal.SizeOf(options);
     ptr = CreateMsgQueue("Test", ref options);
     RequestPowerNotifications(ptr, 0xFFFFFFFF);
     t = new Thread(new ThreadStart(DoWork));
 }