Click here to Skip to main content
15,881,248 members
Articles / Mobile Apps / Windows Mobile

Windows Mobile – Remove the "Backup Battery Very Low" Notification Balloon

Rate me:
Please Sign up or sign in to vote.
4.57/5 (4 votes)
30 Aug 2005CPOL3 min read 64.1K   20   10
How to remove the annoying “Backup Battery Very Low” (bogus) critical notification programmatically.

Introduction

The following code snippet demonstrates a way to programmatically remove "backup battery very low" system notification message-balloon from the system and its icon from the navigation bar of the Windows Mobile device screen. Why this is useful and what problem it solves is being discussed in the next section – “Background”.

Background

Whenever the backup-battery of a device becomes very low, the Windows Mobile based Pocket PC devices would pop up a critical system notification balloon with an icon in the navigation bar to notify the user that the system backup battery is running critically low. This is indeed a critical device condition, and the user is expected to take swift action to replace/recharge the backup battery accordingly to avoid potential data loss.

However, some of the devices that are in the current market either do not have a way to get to where the backup battery is located so that it can be replaced, or for some, even if the battery is replaced, the message-balloon pops up every so often when they cycle the device power, for example. In the latter case, it is a bogus condition, which is annoying to many.

Although, this notification goes away once the user acknowledges the pop up notification, the situation is quite different for applications that are running as Kiosks (full screen mode). In this case, the notification message-balloon never pops up, but the icon is being displayed in the navigation bar, and there is no way to get rid of it.

I found a simple workaround for the above-mentioned situation. You may use the workaround as it fits.

Using the code

The logic behind the workaround is quite simple. There are a couple of tricks involved, though. The logic is to enumerate through the system notifications and find the handle to the "backup-battery very low" notification, and if one is found, remove the notification from the system programmatically.

First of all, be cautious to have a mechanism in place to distinguish the difference between the bogus situation that this notification pops up and the actual condition that the user should take appropriate action to prevent potential data loss.

Second of all, you may need a way to obtain the CLSID for the notification’s COM interface from its text form. You may use CLSIDFromString() function as shown in the code snippet. This function has been implemented in ole32.lib and oleaut32.lib libraries. You may want to #include objbase.h header in your project as well.

Furthermore, the SHNotificationGetData() function call requires a unique notification ID to be passed into the function, which we do not possess. Different platform vendors have assigned different IDs to this same notification making it harder to guess. So, in my workaround, I try different IDs starting from 0 and incrementing by 1 sequentially upon each failed call. In all the platforms that I have tried, there could be a matching ID found within less than 2000 attempts. You may want to experiment for the platforms that you develop first, just to get an idea. It would be nice if your platform vendor can provide you this ID value. If not, you can still use the method that I use.

I have successfully utilized this method in eVC++ 3.0 and 4.0 projects with Windows Mobile 2002/2003/2003SE devices from several vendors.

//*********************************************************************************
//* Method Name: RemoveLowBattMessage()
//*
//* Description: Remove the "Backup Battery Very Low" Notification.
//*
//* Argument(s): none
//* Return type: void
//********************************************************************************
void RemoveLowBattMessage()
{
     SHNOTIFICATIONDATA shnd;
     CLSID clsid;
     LRESULT result;
     DWORD dwID = 0;
 
     if (0 == CLSIDFromString(TEXT("{A877D663-239C-47a7-9304-0D347F580408}"), 
                                                                   &clsid)) {
         memset(&shnd, 0, sizeof(shnd));
         shnd.cbStruct = sizeof(SHNOTIFICATIONDATA);
         do {
              result = SHNotificationGetData(&clsid,dwID,&shnd);
              if (ERROR_SUCCESS == result) {
                   SHNotificationRemove(&clsid,dwID);
                   if (shnd.pszHTML) free((void *) shnd.pszHTML);
                   shnd.pszHTML = NULL;
                   if (shnd.pszTitle) free((void *) shnd.pszTitle);
                   shnd.pszTitle = NULL;
              } else dwID++;
         } while ((ERROR_SUCCESS != result) && (dwID < 2000));
     };
}

Points of Interest

It was great fun for me to think this through. This bogus message has given us a huge annoyance for quite a long time until I came up with this idea to get it removed programmatically. There is nothing magical in this logic. Also, this same approach can be used to remove any of the system notifications that you might not want. Be careful, though!

History

  • August 30th, 2005 – Initial posting to The Code Project.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
United States United States
I work as a Software Design Engineer for Electrical Design Engineering (R&D) at Cyberonics, Inc., Houston Texas, USA. I have been working in a project that involves programming for Windows Mobile based Pocket PC devices. I enjoy chalenges of software engineering, and resolve them, as well as share the solution(s) with fellow developers. In my spare time, I enjoy thinking, surfing web, and play with my daughter. I spend my weekends working in house-cleaning and lawn moving activities.

Comments and Discussions

 
GeneralNice work Pin
JDBP15-Sep-08 14:48
JDBP15-Sep-08 14:48 
QuestionCLSID problem Pin
Pariksheet11-Nov-07 23:21
Pariksheet11-Nov-07 23:21 
GeneralRegarding the CLSID Pin
torbedo11112-Sep-07 17:23
torbedo11112-Sep-07 17:23 
Questionwhere found CLSID ? Pin
jeanp26-Jan-06 4:11
jeanp26-Jan-06 4:11 
AnswerRe: where found CLSID ? Pin
Channa Jayasinghe28-Jan-06 9:00
Channa Jayasinghe28-Jan-06 9:00 
GeneralOr . . . Pin
mbudwick10-Oct-05 23:48
mbudwick10-Oct-05 23:48 
GeneralRe: Or . . . Pin
Channa Jayasinghe11-Oct-05 11:01
Channa Jayasinghe11-Oct-05 11:01 
Arguably, that's correct. However, at least for some of the machines that I have tested, just removing from registry did not seem to work. Smile | :)
QuestionCLSID Pin
Luca Podestà21-Sep-05 20:53
Luca Podestà21-Sep-05 20:53 
GeneralNice Pin
Tony Kmoch30-Aug-05 21:17
Tony Kmoch30-Aug-05 21:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.