Click here to Skip to main content
13,192,426 members (47,308 online)
Click here to Skip to main content

Stats

22.5K views
1.6K downloads
16 bookmarked
Posted 13 Aug 2012

Loading keyboard layout (KbdLayerDescriptor) in 32/64-bit environment

, 13 Aug 2012
When loading a keyboard dll as a 32-bit application on a 64-bit system, the keyboard-dll-files does not work as expected, this class fixes that problem
#pragma  once
#include "kbd.h"
#include "kbd64.h"

//Loaddefs for a 32/64-bit handle of keyboard-loading
typedef PKBDTABLES(* KbdLayerDescriptor)(VOID);
typedef PKBDTABLES64(* KbdLayerDescriptor64)(VOID);
typedef PVOID(*PFN_KBDLAYERDESCRIPTOR)(VOID);

class CKLL
{
public:
	CKLL(void);
	~CKLL(void);

	//Public functions to return info regarding the keyboard-dll loaded
	BOOL	LoadDLL(CString sKeyboardDll);
	USHORT	GetVKCount();
	CString	GetChar(USHORT iVK);
	CString GetSC(USHORT iVK);

	//Return TRUE if x64, false if not...
	BOOL	Is64BitWindows();

private:
	//Our loaded DLL
	HMODULE hHandle;
	void	UnloadDLL();

	//The actual DLL-function that init and fill the array
	PFN_KBDLAYERDESCRIPTOR pfnKbdLayerDescriptor;

	//32-bit variables
	PKBDTABLES KbdTables;
	void Fill32();

	//64-bit variables
	PKBDTABLES64 KbdTables64;
	void Fill64();

	//////////////////////////////////////////////////////////////////////////
	//Structs to handle all keys assigned to a VK
	struct VK_STRUCT
	{
		USHORT nVK;
		CUIntArray aSC;
		CStringArray aChar;
	};

	//Variable to keep track of VKs
	CPtrArray m_vkarray;

	//Function to add / clear new VK-char
	void AddVKChar(USHORT nVK, CString wChar);	//Returns the characters for the available VK
	void AddVKSC(USHORT nVK, USHORT nSC);		//Returns the scan code for the available VK
	int VKExist(USHORT nVK);					//Returns the number in the array for the VK
	void ClearVKChar();							//Clears the table
};

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)

Share

About the Author

Lars [Large] Werner
Engineer
Norway Norway
----------------------------------
Visit http://lars.werner.no/ for my blog!
----------------------------------
Retired programmer, Norway never had the jobs I wanted Smile | :)

You may also be interested in...

Pro
Pro
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.171017.2 | Last Updated 13 Aug 2012
Article Copyright 2012 by Lars [Large] Werner
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid