public CE_NOTIFICATION_INFO_HEADER(byte[] Buf, uint Size) { int Index = 0; try { this.hNotification = BitConverter.ToUInt32(Buf, Index); Index += 4; this.dwStatus = BitConverter.ToUInt32(Buf, Index); Index += 4; uint pcent = BitConverter.ToUInt32(Buf, Index); Index += 4; uint pceun = BitConverter.ToUInt32(Buf, Index); Index += 4; if (pcent > 0 && Buf[Index] == Marshal.SizeOf(new CE_NOTIFICATION_TRIGGER())) { this.cent = new CE_NOTIFICATION_TRIGGER(Buf, Size, ref Index); } if (pceun > 0) { this.ceun = new CE_USER_NOTIFICATION(Buf, Size, ref Index); } } catch (Exception ex) { throw ex; } }
/* * The following code will create a time based trigger and connect that trigger to a notification that will fire up \windows\fexplore.exe. * Note that you need to compile this sample with the /unsafe switch. You could always hard code the size of CE_NOTIFICATION_TRIGGER in which case /unsafe won't be necessary. If hard coded; the value is 52. * Also don't forget to pass NULL instead of ceun if you change the trigger type to CNT_EVENT. */ public void newRunAtTime(SYSTEMTIME stStart, SYSTEMTIME stEnd) { CE_NOTIFICATION_TRIGGER cnt = new CE_NOTIFICATION_TRIGGER(); CE_USER_NOTIFICATION ceun = new CE_USER_NOTIFICATION(); cnt.Type = CeNotificationType.CNT_TIME; cnt.StartTime = stStart; cnt.EndTime = stEnd; cnt.pApplication = @"\windows\fexplore.exe"; cnt.pArgs = ""; cnt.Size = (UInt32)Marshal.SizeOf(cnt); // Needs to compile with /unsafe ceun.ActionFlags = PUN_FLAGS.PUN_LED; ceun.sDialogText = "Dialogtext"; ceun.sDialogTitle = "Title"; ceun.nMaxSound = 0; uint hNotificationEx = SetUserNotificationEx(0, cnt, ceun); if (hNotificationEx > 0) { MessageBox.Show("Successfully created a notification. Handle: " + hNotificationEx.ToString()); } else { MessageBox.Show("Failed to create a notification"); } }
void DataCollection() { NamedEvents namedEvent = new NamedEvents(); NamedEvents waitDisconnectEvent = new NamedEvents(); while (true) { //on receive a disconnect, insert an event and wakeup after 1 minute string appName = "\\\\.\\Notifications\\NamedEvents\\WocketsEvent" + reminderID; string args = ""; CE_NOTIFICATION_TRIGGER notificationTrigger = new CE_NOTIFICATION_TRIGGER(); notificationTrigger.Type = 2; notificationTrigger.pAppName = appName; notificationTrigger.pArgs = args; notificationTrigger.StartTime = new SYSTEMTIME(reminderDateTime); notificationTrigger.EndTime = new SYSTEMTIME(); notificationTrigger.Size = (UInt32)Marshal.SizeOf(notificationTrigger); // This line needs the compile switch /unsafe IntPtr notificationHandle = CeSetUserNotificationEx(IntPtr.Zero, notificationTrigger, null); reminderDateTime = reminderDateTime.AddSeconds(60); namedEvent.Receive("WocketsEvent" + reminderID++); SystemIdleTimerReset(); try { Wockets.Utils.network.NetworkStacks._BluetoothStack.Initialize(); } catch { } Thread.Sleep(3000); for (int i = 0; (i < this._Sensors.Count); i++) { countSeconds[i] = true; ((WocketsDecoder)this._Decoders[i])._ExpectedBatchCount = -1; this._Sensors[i]._ReceivedPackets = 0; ((RFCOMMReceiver)this._Receivers[i])._Reconnections = 0; } connecting = true; this._Polling = true; namedEvent.Reset(); CeClearUserNotification((int)notificationHandle); } }
public static void RunApplication(string application, string arguments, NOTIFICATION_EVENT notificationEvent) { CE_NOTIFICATION_TRIGGER nt = new CE_NOTIFICATION_TRIGGER(application, arguments, notificationEvent); using ( nt ) { IntPtr hNotify = CeSetUserNotificationEx(IntPtr.Zero, ref nt, IntPtr.Zero); if (hNotify == IntPtr.Zero) { throw new Win32Exception(Marshal.GetLastWin32Error()); } } }
public static void NotifyDialog(string title, string text, DateTime start) { CE_NOTIFICATION_TRIGGER nt = new CE_NOTIFICATION_TRIGGER(start); CE_USER_NOTIFICATION un = new CE_USER_NOTIFICATION(title, text); using (nt) using ( un ) { IntPtr hNotify = CeSetUserNotificationEx(IntPtr.Zero, ref nt, ref un); if (hNotify == IntPtr.Zero) { throw new Win32Exception(Marshal.GetLastWin32Error()); } } }
public void runAppAtTime(string sApp, SYSTEMTIME stStart, SYSTEMTIME stEnd) { CE_NOTIFICATION_TRIGGER cnt = new CE_NOTIFICATION_TRIGGER(); cnt.Type = CeNotificationType.CNT_TIME; cnt.StartTime = stStart; cnt.EndTime = stEnd; cnt.pApplication = @"\windows\fexplore.exe"; cnt.pArgs = ""; cnt.Size = (UInt32)Marshal.SizeOf(cnt); // Needs to compile with /unsafe uint hNotificationEx = SetUserNotificationEx(0, cnt, null); if (hNotificationEx > 0) { MessageBox.Show("Successfully created a notification. Handle: " + hNotificationEx.ToString()); } else { MessageBox.Show("Failed to create a notification"); } }
private static extern IntPtr CeSetUserNotificationEx( IntPtr h, ref CE_NOTIFICATION_TRIGGER nt, IntPtr un );
private static extern IntPtr CeSetUserNotificationEx(IntPtr notification, CE_NOTIFICATION_TRIGGER notificationTrigger, CE_USER_NOTIFICATION userNotification);
public static extern uint SetUserNotificationEx([MarshalAs(UnmanagedType.U4)] uint hNotification, CE_NOTIFICATION_TRIGGER Trigger, CE_USER_NOTIFICATION Notification);
public void runAppAtTime(string sApp, SYSTEMTIME stStart, SYSTEMTIME stEnd) { CE_NOTIFICATION_TRIGGER cnt = new CE_NOTIFICATION_TRIGGER(); cnt.Type = CeNotificationType.CNT_TIME; cnt.StartTime = stStart; cnt.EndTime = stEnd; cnt.pApplication = @"\windows\fexplore.exe"; cnt.pArgs = ""; cnt.Size = (UInt32)Marshal.SizeOf(cnt); // Needs to compile with /unsafe uint hNotificationEx = SetUserNotificationEx(0, cnt, null); if (hNotificationEx > 0) MessageBox.Show("Successfully created a notification. Handle: " + hNotificationEx.ToString()); else MessageBox.Show("Failed to create a notification"); }
public static extern uint SetUserNotificationEx([MarshalAs(UnmanagedType.U4)]uint hNotification, CE_NOTIFICATION_TRIGGER Trigger, CE_USER_NOTIFICATION Notification);
public CE_NOTIFICATION_INFO_HEADER(byte[] Buf, uint Size) { int Index = 0; try { this.hNotification = BitConverter.ToUInt32(Buf, Index); Index += 4; this.dwStatus = BitConverter.ToUInt32(Buf, Index); Index += 4; uint pcent = BitConverter.ToUInt32(Buf, Index); Index += 4; uint pceun = BitConverter.ToUInt32(Buf, Index); Index += 4; if (pcent > 0 && Buf[Index] == Marshal.SizeOf(new CE_NOTIFICATION_TRIGGER())) this.cent = new CE_NOTIFICATION_TRIGGER(Buf, Size, ref Index); if (pceun > 0) this.ceun = new CE_USER_NOTIFICATION(Buf, Size, ref Index); } catch (Exception ex) { throw ex; } }
/* The following code will create a time based trigger and connect that trigger to a notification that will fire up \windows\fexplore.exe. Note that you need to compile this sample with the /unsafe switch. You could always hard code the size of CE_NOTIFICATION_TRIGGER in which case /unsafe won't be necessary. If hard coded; the value is 52. Also don't forget to pass NULL instead of ceun if you change the trigger type to CNT_EVENT. */ public void newRunAtTime(SYSTEMTIME stStart, SYSTEMTIME stEnd){ CE_NOTIFICATION_TRIGGER cnt = new CE_NOTIFICATION_TRIGGER(); CE_USER_NOTIFICATION ceun = new CE_USER_NOTIFICATION(); cnt.Type =CeNotificationType.CNT_TIME; cnt.StartTime = stStart; cnt.EndTime = stEnd; cnt.pApplication = @"\windows\fexplore.exe"; cnt.pArgs = ""; cnt.Size = (UInt32)Marshal.SizeOf(cnt); // Needs to compile with /unsafe ceun.ActionFlags = PUN_FLAGS.PUN_LED; ceun.sDialogText = "Dialogtext"; ceun.sDialogTitle = "Title"; ceun.nMaxSound = 0; uint hNotificationEx = SetUserNotificationEx(0, cnt, ceun); if (hNotificationEx > 0) MessageBox.Show("Successfully created a notification. Handle: " + hNotificationEx.ToString()); else MessageBox.Show("Failed to create a notification"); }
public static void RunApplication( string application, string arguments, NOTIFICATION_EVENT notificationEvent ) { CE_NOTIFICATION_TRIGGER nt = new CE_NOTIFICATION_TRIGGER( application, arguments, notificationEvent ); using( nt ) { IntPtr hNotify = CeSetUserNotificationEx( IntPtr.Zero, ref nt, IntPtr.Zero ); if( hNotify == IntPtr.Zero ) { throw new Win32Exception( Marshal.GetLastWin32Error() ); } } }
public static void NotifyDialog( string title, string text, NOTIFICATION_EVENT notificationEvent ) { CE_NOTIFICATION_TRIGGER nt = new CE_NOTIFICATION_TRIGGER( notificationEvent ); CE_USER_NOTIFICATION un = new CE_USER_NOTIFICATION( title, text ); using( nt ) using( un ) { IntPtr hNotify = CeSetUserNotificationEx( IntPtr.Zero, ref nt, ref un ); if( hNotify == IntPtr.Zero ) { throw new Win32Exception( Marshal.GetLastWin32Error() ); } } }