Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

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
KeyboardLayout-noexe.zip
KeyboardLayout
KeyboardLayout
KeyboardLayout.vcxproj.filters
KeyboardLayout.vcxproj.user
res
KeyboardLayout.ico
KeyboardScancodes.bmp
KeyboardLayout.suo
KeyboardLayout.zip
KeyboardLayout.vcxproj.filters
KeyboardLayout.vcxproj.user
KeyboardLayout.ico
KeyboardScancodes.bmp
KeyboardLayout.suo
KLL.zip
#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
I'm looking for new opportunities in Norway, contact me on email, twitter or Facebook
Not able to travel (a lot) so either home office or in Telemark area, Norway.
 
----------------------------------
Visit http://lars.werner.no/ for my techno-blog!
----------------------------------
 
Projects
* Adito - Simple Windows installer for Adito/OpenVPN ALS!
* Unpacker - Auto extract of multiple archives (RAR/ZIP) with queue support and cleanup options!
* SizeMe - Ultimate tool for maximize your output on CD/DVDs!
Follow on   Twitter   Google+

| Advertise | Privacy | Mobile
Web04 | 2.8.140827.1 | Last Updated 13 Aug 2012
Article Copyright 2012 by Lars [Large] Werner
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid