Вот путь C
#include <windows.h>
#define err if (GetLastError() != 0) return GetLastError();
extern "C" __declspec(dllexport) int __stdcall TurnLed(int state)
{
DWORD tmp = 4;
DWORD buf = (2*GetKeyState(VK_NUMLOCK) + 4*GetKeyState(VK_CAPITAL) + state)<<16;
DefineDosDevice(DDD_RAW_TARGET_PATH, "Kbd", "\\Device\\KeyboardClass1"); err
HANDLE kbd = CreateFile("\\\\.\\Kbd", GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); err
DeviceIoControl(kbd, CTL_CODE(FILE_DEVICE_KEYBOARD, 0x0002, METHOD_BUFFERED, FILE_ANY_ACCESS), &buf, sizeof(buf), 0, 0, &tmp, 0); err
DefineDosDevice(DDD_REMOVE_DEFINITION, "Kbd", 0); err
CloseHandle(kbd); err
return 0;
}