To control the Notification LEDs in Windows Mobile, we can use the API NLedSetDevice. The syntax of is defined as:

BOOL WINAPI NLedSetDevice(UINT nDeviceId,void* pInput);

The nDeviceId parameter specifies the type of information to set. The only supported value is NLED_SETTINGS_INFO_ID, which set the sets the settings for the Notification LED. The second parameter is a pointer to NLED_SETTINGS_INFO structure, which is defined as:

struct NLED_SETTINGS_INFO {
UINT LedNum;
INT OffOnBlink;
LONG TotalCycleTime;
LONG OnTime;
LONG OffTime;
INT MetaCycleOn;
INT MetaCycleOff;
};

There could be more than one LED present in the device. You can specify which LED to control in the LedNum member. The following code snippet controls the LED on or off:

void SetLED(int nLed,BOOL bOn)
{
NLED_SETTINGS_INFO sInfo;

ZeroMemory(&sInfo,sizeof(NLED_SETTINGS_INFO));

sInfo.LedNum = nLed;
sInfo.OffOnBlink = bOn ? 1 : 0;

NLedSetDevice(NLED_SETTINGS_INFO_ID, &sInfo);
}

The following code retrieves the number of LEDs present in the device:

NLED_COUNT_INFO sCount = {0};

NLedGetDeviceInfo(NLED_COUNT_INFO_ID,&sCount);