LKBDE11277: Ein C oder C++ Programm für Windows, um NUMLock zu aktivieren
LKB | Created: 02/04/2020 | Version: 1 | Language: DE | Rating: 0 | Outdated: False | Marked for deletion: False
Author: Wim Peeters - Keskon GmbH & Co. KG
Latest update: 19/09/2020 | Comment:
Symptom
Numlock wird nicht über die Registry mit "InitialKeyboardIndicators" = 2 gesetzt
Cause
Die Registry ist nicht immer die Lösung
Solution
Ich habe eine kleine Anwendung in C geschrieben, die die NUMLock Taste checkt und setzen kann. Du kannst es in einem C Compiler erzeugen oder ggf. im Downloadbereicht von Lubby herunterladen.
Im folgenden Beispiel wird das Programm in ein Anmeldeskript mit Hilfe von VBScript eingebunden:
Set oShell = WScript.CreateObject ("WSCript.shell")
oShell.run "cmd /C CD C:\ & %logonserver%\netlogon\NUMLOCK-on.exe"
----------------------------
C Quellcode:
// NUMLOCK-on.cpp : Programmed by Wim Peeters.
//
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
SHORT myshort;
int thekey; //#define VK_NUMLOCK 0x90 can be found in winuser.h (Wim)
thekey=144; //this should be 0x90 VK_NUMLOCK
myshort = GetKeyState(thekey);
printf("Programmed by Wim Peeters\n");
//printf("your NUMLOCK key is %d\n",myshort);
if(myshort==1)
{
printf("NUMLOCK is already on\n");
}
else
{
printf("NUMLOCK is off, switching it to on\n");
keybd_event(thekey,1,0,0);
keybd_event(thekey,1,KEYEVENTF_KEYUP,0);
}
return 0;
}
About the Author
Wim Peeters is electronics engineer with an additional master in IT and over 30 years of experience including time spent in support, development, consulting, training and database administration. Wim has worked with SQL Server since version 6.5. He has developed in C/C++, Java and C# on Windows and Linux in different European countries and different European languages. He writes knowledge base articles to solve IT problems and publishes them on the Lubby Knowledge Platform where he is one of the most important contributors and the main developer.