Stephane Sibue (webmaster@codeppc.com), January 11, 2001.
The LED is a part of Pocket PC specification. Generally it allows
to indicate either that the battery is attached or that the Pocket PC is
directly connected to the cradle. A Pocket PC can implement several LEDS,
but usually there is only one.
This article is translated from CodePPC.com.
Functions for handling LEDs can be found in 'coredll.dll' library, but they are not declared in the SDK (who knows why?). It is only the 'NLed.h' file that can make them appear, but the prototypes of the functions are not declared in this file.
The first thing to do is to include the 'NLed.h' file and to declare 2 functions for handling LEDs:
Initially, it is necessary to know how many LEDs are present, knowing that the number of the first one is 0. To carry out this checking, we will use the 'NLedGetDeviceInfo' function:
In case of a problem, this function returns 0. It also returns 0 if a Pocket PC does not have a LED to handle. In 99 cases out of a hundred this function returns 1.
We can now modify the state of our LED. According to the contents of the 'NLed.h' file, the LED can appear in 3 states: off, on, and blink (stop, functioning, and blinking). Each state corresponds to a value of the 'OffOnBlink' parameter of the 'NLED_SETTINGS_INFO' structure. This structure also allows to implement other effects but this exceeds the topic of this article, we will return to this implementation later. Thus we will create a function, which takes the desired state of our LED as a parameter, which can be 0 for idle (off), 1 for fixed functioning (on), and 2 for the effect of blinking (blink):
Thus, to light up the LED n°1, it is enough to write:
to make it blink:
and finally to estinguish it: