Board index » cppbuilder » WriteBinaryData

WriteBinaryData


2004-08-09 07:01:08 AM
cppbuilder63
Hello,
Here is what I've done:
char valuedata[255] = "00 00 00 00 00 00 00 00 03 00 00 00 00 00 5B E0 00 00
5C E0 00 00 00 00";
TRegistry * Registry = new TRegistry(KEY_ALL_ACCESS);
Registry->RootKey = HKEY_LOCAL_MACHINE;
if(Registry->OpenKey("SYSTEM\\CurrentControlSet\\Control\\Keyboard Layout",
true)){
Registry->WriteBinaryData("Scancode Map",valuedata, 128);
Registry->CloseKey();
delete Registry;
In the registry, "ScanCode Map" should contain the following value data: 00
00 00 00 00 00 00 00 03 00 00 00 00 00 5B E0 00 00 5C E0 00 00 00 00
But this is not what I have... I shouldn't use char ?
 
 

Re:WriteBinaryData

"kevinz" < XXXX@XXXXX.COM >wrote in message
Quote
But this is not what I have... I shouldn't use char ?
You are not using it correctly, no. You are trying to store a string while
it is expecting actual binary data instead. The two are not the same at
all. Use this code instead:
#pragma pack(push, 1)
typedef struct
{
DWORD Version;
DWORD Flags;
DWORD NumberOfEntries;
DWORD Entries[1];
} SCANCODEMAP, *LPSCANCODEMAP;
#pragma pack(pop)
{
BYTE buffer[24];
LPSCANCODEMAP Map = (LPSCANCODEMAP) &buffer[0];
Map->Version = 0;
Map->Flags = 0
Map->NumberOfEntries = 3;
LPDWORD Entries = Map->Entries;
Entries[0] = 0xE05B0000;
Entries[1] = 0xE05C0000;
Entries[2] = 0;
TRegistry * Registry = new TRegistry(KEY_WRITE);
Registry->RootKey = HKEY_LOCAL_MACHINE;
if( Registry->OpenKey("SYSTEM\\CurrentControlSet\\Control\\Keyboard
Layout", true))
{
Registry->WriteBinaryData("Scancode Map", buffer, 24);
Registry->CloseKey();
}
delete Registry;
}
You can read the following article for more details:
Disabling the Windows Key on Microsoft Natural Keyboard
support.microsoft.com/default.aspx
Gambit