Getting and setting NumLock state in Lazarus

541 Views Asked by At

Is there a reliable cross-platform way to programmatically get and set the NumLock state in Lazarus / Free Pascal?

I've found GetKeyState() in LclIntf which seems to work for getting the state (and is apparently cross-platform), but I can't find an equivalent SetKeyState().

1

There are 1 best solutions below

0
On

Setting leds is rarely part of an userland API, since keyboard leds are hardware, and will require administrator access on most systems.

IIRC I did it once for FreeBSD using the console unit. (which basically sends IOCTLs), Linux is probably similar.

For Windows I found http://support.microsoft.com/kb/177674/en-us, but the fact that it is not an universal call, and differs between win9x and winnt says enough.