//TH-Header //***************************************************************************************** // Copyright (c) 2001 Michael Kurz // All rights reserved. // If you want to use this source in your applications conatct: // // $FileName : mWinAPIGetKeyNameText.pkg // $ProjectName : Shared Methods // $Author : Michael Kurz // $Created : 01.05.2001 20:02 // // Contents: // -WinAPIGetKeyNameText integer iVirtualKeyCode returns string // // Gets the name of a VK key code. //***************************************************************************************** //TH-RevisionStart //TH-RevisionEnd #IFNDEF GET_MAPVIRTUALKEY #IF (!@ < 200) External_function MapVirtualKey "MapVirtualKeyA" User32.dll UInteger uCode UInteger uMapType Returns Integer #ELSE External_Function MapVirtualKey "MapVirtualKeyW" User32.dll UInteger uCode UInteger uMapType Returns Integer #ENDIF #ENDIF #IF (!@ < 200) External_function GetKeyNameText "GetKeyNameTextA" User32.dll UInteger iKey Pointer pBuff Integer iSize Returns Integer #ELSE External_function GetKeyNameText "GetKeyNameTextW" User32.dll UInteger iKey Pointer pBuff Integer iSize Returns Integer #ENDIF // Retrieves the name of a key. (Virtual KeyCode) Function WinAPIGetKeyNameText Global Integer iKey Returns String Integer iRet String sBuff #IF (!@ < 200) Move (Repeat(Character(0),1024)) To sBuff Move (MapVirtualKey(iKey,0)) To iKey Move (iKey*65536) To iKey Move (GetKeyNameText(iKey,AddressOf(sBuff),1024)) To iRet If iRet Eq 0 ; Move "" To sBuff Else ; Move (Cstring(sBuff)) To sBuff #ELSE WString wBuff Move (Repeat(Character(0),1024)) To wBuff Move (MapVirtualKey(iKey,0)) To iKey Move (iKey*65536) To iKey Move (GetKeyNameText(iKey,AddressOf(wBuff),1024)) To iRet If iRet Eq 0 ; Move "" To sBuff Else ; Move (Cstring(wBuff)) To sBuff #ENDIF Function_Return sBuff End_Function