// 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)Marshal.SizeOf(options); ptr = CreateMsgQueue("Test", ref options); RequestPowerNotifications(ptr, POWER_NOTIFY_ALL); t = new Thread(DoWork); t.Name = "Power events listening thread"; }
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);