Click here to Skip to main content
Click here to Skip to main content

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

By , 30 Aug 2005
Rate this:
Please Sign up or sign in to vote.

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)

About the Author

Channa Jayasinghe
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 PinmemberJDBP15-Sep-08 14:48 
QuestionCLSID problem PinmemberPariksheet11-Nov-07 23:21 
GeneralRegarding the CLSID Pinmembertorbedo11112-Sep-07 17:23 
Questionwhere found CLSID ? Pinmemberjeanp26-Jan-06 4:11 
AnswerRe: where found CLSID ? PinmemberChanna Jayasinghe28-Jan-06 9:00 
GeneralOr . . . Pinmembermbudwick10-Oct-05 23:48 
GeneralRe: Or . . . PinmemberChanna Jayasinghe11-Oct-05 11:01 
QuestionCLSID PinmemberLuca Podestà21-Sep-05 20:53 
GeneralNice PinmemberTony Kmoch30-Aug-05 21:17 

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

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

| Advertise | Privacy | Mobile
Web04 | 2.8.140415.2 | Last Updated 30 Aug 2005
Article Copyright 2005 by Channa Jayasinghe
Everything else Copyright © CodeProject, 1999-2014
Terms of Use
Layout: fixed | fluid