/// <summary> /// /// </summary> /// <param name="pointer"></param> /// <returns></returns> internal static UserNotificationInfoHeader FromPtr(IntPtr pointer) { UserNotificationInfoHeader nih = new UserNotificationInfoHeader(); Marshal.Copy(pointer, nih.data, 0, Size); //marshall trigger nih.trigger = UserNotificationTrigger.FromPtr((IntPtr)BitConverter.ToInt32(nih.data, 8)); //marshall notification IntPtr notifyptr = (IntPtr)BitConverter.ToInt32(nih.data, 12); //if null pointer no notification if (notifyptr != IntPtr.Zero) { //else convert to managed notificatio object nih.notify = UserNotification.FromPtr(notifyptr); } return(nih); }
/// <summary> /// Retrieves notification information associated with a handle. /// </summary> /// <param name="handle">Handle to the user notification to retrieve.</param> /// <returns>The requested UserNotification.</returns> public static UserNotificationInfoHeader GetUserNotification(int handle) { //buffer size int size = 0; //first query for buffer size required CeGetUserNotification(handle, 0, ref size, IntPtr.Zero); //create a marshallable buffer IntPtr buffer = MarshalEx.AllocHGlobal(size); //call native getter if (!CeGetUserNotification(handle, (uint)size, ref size, buffer)) { throw new Win32Exception(Marshal.GetLastWin32Error(), "Error getting UserNotification"); } UserNotificationInfoHeader nih = UserNotificationInfoHeader.FromPtr(buffer); //free native memory MarshalEx.FreeHGlobal(buffer); return(nih); }
/// <summary> /// /// </summary> /// <param name="pointer"></param> /// <returns></returns> internal static UserNotificationInfoHeader FromPtr(IntPtr pointer) { UserNotificationInfoHeader nih = new UserNotificationInfoHeader(); Marshal.Copy(pointer, nih.data, 0, Size); //marshall trigger nih.trigger = UserNotificationTrigger.FromPtr((IntPtr)BitConverter.ToInt32(nih.data, 8)); //marshall notification IntPtr notifyptr = (IntPtr)BitConverter.ToInt32(nih.data, 12); //if null pointer no notification if(notifyptr!=IntPtr.Zero) { //else convert to managed notificatio object nih.notify = UserNotification.FromPtr(notifyptr); } return nih; }