Hy I need some help on Keyboard Layout:
With this function I load keyboard layout
HINSTANCE loadKeyboardLayout()
{
PKBDTABLES pKbd;
HINSTANCE kbdLibrary;
KbdLayerDescriptor pKbdLayerDescriptor = NULL;
char layoutFile[MAX_PATH]; //char
if(getKeyboardLayoutFile(layoutFile, sizeof(layoutFile)) == -1)
return NULL;
char systemDirectory[MAX_PATH];
GetSystemDirectory(systemDirectory, MAX_PATH);
char kbdLayoutFilePath[MAX_PATH];
snprintf(kbdLayoutFilePath, MAX_PATH, "%s\\%s", systemDirectory, layoutFile);
kbdLibrary = LoadLibrary(kbdLayoutFilePath);
pKbdLayerDescriptor = (KbdLayerDescriptor)GetProcAddress(kbdLibrary, "KbdLayerDescriptor");
if(pKbdLayerDescriptor != NULL)
pKbd = pKbdLayerDescriptor();
else
return NULL;
int i = 0;
do
{
INIT_PVK_TO_WCHARS(i, 1)
INIT_PVK_TO_WCHARS(i, 2)
INIT_PVK_TO_WCHARS(i, 3)
INIT_PVK_TO_WCHARS(i, 4)
INIT_PVK_TO_WCHARS(i, 5)
INIT_PVK_TO_WCHARS(i, 6)
INIT_PVK_TO_WCHARS(i, 7)
INIT_PVK_TO_WCHARS(i, 8)
INIT_PVK_TO_WCHARS(i, 9)
INIT_PVK_TO_WCHARS(i, 10)
i++;
}
while(pKbd->pVkToWcharTable[i].cbSize != 0);
pCharModifiers = pKbd->pCharModifiers;
pDeadKey = pKbd->pDeadKey;
return kbdLibrary;
}
and there I get layout keyboard:
int getKeyboardLayoutFile(char* layoutFile, DWORD bufferSize)
{
HKEY hKey;
DWORD varType = REG_SZ;
char kbdName[KL_NAMELENGTH];
GetKeyboardLayoutName(kbdName);
char kbdKeyPath[51 + KL_NAMELENGTH];
snprintf(kbdKeyPath, 51 + KL_NAMELENGTH,
"SYSTEM\\CurrentControlSet\\Control\\Keyboard Layouts\\%s", kbdName);
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, (LPCTSTR)kbdKeyPath, 0, KEY_QUERY_VALUE, &hKey) =! ERROR_SUCCESS)
return -1;
if (RegQueryValueEx(hKey, "Layout File", NULL, &varType, layoutFile, &bufferSize) != ERROR_SUCCESS) //jeigu ne ERROR_SUCCESS
return -1; //this is error
RegCloseKey(hKey);
end gets 2 errors:
error: invalid conversion from 'char*' to 'BYTE*'|
error: initializing argument 5 of 'LONG RegQueryValueExA(HKEY__*, const CHAR*, DWORD*, DWORD*, BYTE*, DWORD*)'|
on..
if (RegQueryValueEx(hKey, "Layout File", NULL, &varType, layoutFile, &bufferSize) != ERROR_SUCCESS) //jeigu ne ERROR_SUCCESS
return -1; //this is error
How I understant conversion problem is on layoutFile variable. In first code how I can see it is char tipe. Any mind how to solve this error?