use imm;
var
hKL : LongInt;
byteBuf : PByte;
hImc: THandle;
lngLen : integer;
lngRet : LongInt;
dwSize : LongInt;
begin
edtAnswer.Text := '가';
hKL := GetKeyboardLayout(0);
hImc := ImmGetDefaultIMEWnd(edtAnswer.Handle);
lngLen := ImmGetConversionList(hKL,hImc,PChar(edtAnswer.Text),nil,0,GCL_CONVERSION);
if lngLen > 0 then
lngRet := ImmGetConversionList(hKL,hImc,PChar(edtAnswer.Text),@byteBuf,lngLen, GCL_CONVERSION);
dwSize := byteBuf^;
ImmReleaseContext(Handle, hImc);
end;
위와 같이 하였더니 에러는 나지 않는데 @byteBuf에 $140이라는 값이 들어오는데 이후 어떻게 변환하나요?
dwSize := byteBuf^ 에서 0x0000dd 에러가 나네요.
무엇이 잘못 되었는지 고수님들의 고견 부탁드립니다.
procedure TfrmMain.Button1Click(Sender: TObject);
var
IMC: HIMC;
KL: HKL;
ErrorCode: LongWord;
Buffer: PByteArray;
BufferSize: Integer;
HanjaList: string;
CandidateList: PCandidateList absolute Buffer;
Index: Integer;
begin
Edit1.Text := '가';
KL := GetKeyboardLayout(0);
Imc := ImmGetDefaultIMEWnd(Edit1.Handle);
BufferSize := ImmGetConversionList(KL, IMC, PChar(Edit1.Text), nil, 0, GCL_CONVERSION);
if BufferSize <> 0 then
begin
GetMem(Buffer, BufferSize);
FillChar(Buffer^, BufferSize, 0);
try
ErrorCode := ImmGetConversionList(KL, IMC, PChar(Edit1.Text), CandidateList, BufferSize, GCL_CONVERSION);
SetLength(HanjaList, BufferSize - CandidateList.dwOffset[1]);
Move(Buffer[CandidateList.dwOffset[1]], HanjaList[1], BufferSize - CandidateList.dwOffset[1]);
for Index := 1 to Length(HanjaList) do
begin
if HanjaList[Index] = #0 then
HanjaList[Index] := #32;
end;
Memo1.Lines.Add(HanjaList);
finally
FreeMem(Buffer, BufferSize)
end;
end;
ImmReleaseContext(Handle, IMC);
end;