From: neridan@central.co.nz (Neil Daniell) Setting / Unsetting NumLock Status in OS/2 App [1] Required variables: HFILE hfile; // File handle for device ULONG ulAction; ULONG ulLength; BYTE KeyState[257]; SHIFTSTATE strShiftState; unsigned short usLightState; [2] Open keyboard device for use with DosDevIOCtl: DosOpen ( "KBD$", &hfile, &ulAction, 0L, 0, FILE_OPEN, OPEN_ACCESS_READONLY | OPEN_SHARE_DENYNONE, 0 ); [3] Obtain Shift Status information using DosDevIOCtl Category IOCTL_KEYBBOARD ( 0x0004 ) Function KBD_GETSHIFTSTATE ( 0x0073 ) ulAction = 0; ulLength = sizeof ( strShiftState ); DosDevIOCtl ( hfile, IOCTL_KEYBOARD, KBD_GETSHIFTSTATE, 0, 0, &ulAction, &strShiftState, sizeof( strShiftState ), &ulLength ); [4] Get Keyboard state table: WinSetKeyboardStateTable ( HWND_DEKSTOP, &KeyState[1], FALSE ); [5] Set shift and key state: If setting key ON: KeyState[VK_NUMLOCK+1] |= 0x01; strShiftState.fsState |= NUMLOCK_ON; If setting key OFF: KeyState[VK_NUMLOCK+1] &= ~0x01; strShiftState.fsState &= ~NUMLOCK_ON; [6] Update keyboard state table: WinSetKeyboardStateTable ( HWND_DEKSTOP, &KeyState[1], TRUE ); [7] Update shift state: using DosDevIOCtl Category IOCTL_KEYBBOARD ( 0x0004 ) Function KBD_SETSHIFTSTATE ( 0x0053 ) ulAction = sizeof ( strShiftState ); ulLength = 0; DosDevIOCtl ( hfile, IOCTL_KEYBOARD, KBD_SETSHIFTSTATE, &strShiftState, sizeof( strShiftState ), &ulAction, 0, 0, &ulLength ); [8] Set LED status using DosDevIOCtl Category IOCTL_KEYBBOARD ( 0x0004 ) Function KBD_ALTERKEYBOARDLED ( 0x005A ) NB: This constant is NOT predefined, will require specific declaration. usLightState = ( strShifState.fsState & ( CAPSLOCK_ON | NUMLOCK_ON | SCROLLLOCK_ON ) ) >> 4; ulAction = sizeof ( usLightState ); DosDevIOCtl ( hfile, IOCTL_KEYBOARD, KBD_ALTERKEYBOARDLED, &usLightState, sizeof( usLightState ), &ulAction, 0, 0, &ulLength ); [9] Close device: DosClose ( hfile );