I am using this code to convert a virtual key to WideString:
function VKeytoWideString (Key : Word) : WideString;
var
WBuff : array [0..255] of WideChar;
KeyboardState : TKeyboardState;
UResult : Integer;
begin
Result := '';
GetKeyBoardState (KeyboardState);
ZeroMemory(@WBuff[0], SizeOf(WBuff));
UResult := ToUnicode(key, MapVirtualKey(key, 0), KeyboardState, WBuff, Length(WBuff), 0);
if UResult > 0 then
SetString(Result, WBuff, UResult)
else if UResult = -1 then
Result := WBuff;
end;
It works fine on my PC, but on a Chinese PC I get this:
It converts the Chinese chars to Hanyu Pinyin. I think the function actually returns the raw input of the keyboard and not what the user actually wants to type in.
How should I handle this?

As per the comments, here is an example of how you can avoid the problem by handling
KeyPressevents instead of manually convertingKeyDownevents. The TNT controls don’t provide aWideCharKeyPressevent, but it’s fairly easy to add. Ideally, you should not put the extensions toTTntMemoandTTntFormin derived classes as I’ve done here, but instead modify the TNT source code.The form contains two
TTntMemocontrols. Pressing keys in the first will log the events in the second.