So you used one of the notification functions, like CeRunAppAtEvent() or CeRunAppAtTime(), to request that an app or event be signaled when a system event occurs. Now you want to disable the event notification, well that is easy just call the same function again but with different parameters to disable it. Let’s look at this:
                // Ask the system to run repllog.exe when a cable is connected.
                CeRunAppAtEvent(TEXT("repllog.exe"), NOTIFICATION_EVENT_RS232_DETECTED);
 
                ... do other stuff
 
                // Ask the system to not run repllog.exe when a cable is connected
                CeRunAppAtEvent(TEXT("repllog.exe"), NOTIFICATION_EVENT_NONE);
This simple code sets up the notification system to run repllog.exe when a cable is connected, then removes repllog.exe from the notification system.
Sure, simple enough, that is until a customer contacted me and said that the code to remove repllog.exe doesn’t work. So I tried it, like this:
                // Ask the system to not run repllog.exe when a cable is connected
                CeRunAppAtEvent(TEXT("Repllog.exe"), NOTIFICATION_EVENT_NONE);
Nothing, it didn’t get removed from the notification system. For how I determined this see Windows CE: Enumerating User Notifications. But, enumerating the user notifications gave me a hint. The repllog.exe notifications output looked like:
      Status 0
       Trigger Type 1 Event
       Trigger Event 9 RS232 Detected
       Trigger Application repllog.exe
       Trigger Arguments AppRunAtRs232Detect
       Trigger EndTime 0/0/0 0:00
       Trigger StartTime 0/0/0 0:00
Looking at this, you should notice that the Trigger Application is all lower case, “repllog.exe” but my call was mixed case “Repllog.exe”. Hmm, could it be case sensitive? Yes, it appears to be. So changing the uppercase R to lower case r works.
So two lessons learned; case sensitive string and we probably should check the return value.   The following will remove repllog.exe and if it fails the code will know it:
                // Ask the system to not run repllog.exe when a cable is connected
                if( !CeRunAppAtEvent(TEXT("repllog.exe"), NOTIFICATION_EVENT_NONE) )
                {
                                // Failed to remove the notification, let the user know
                }
                                                                                                                                 
Copyright © 2009 – Bruce Eitman
All Rights Reserved