1

如何使用 JNA 从记事本中获取文本?

我尝试了以下代码:

    public final int WM_GETTEXT = 0x00D;
    public final int WM_GETTEXTLENGTH = 0x00A;
    ...

    byte[] windowText = new byte[512];
    WinDef.LRESULT res = User32.INSTANCE.SendMessage(hwnd, User32.WM_GETTEXTLENGTH, 0, 0);
    User32.INSTANCE.SendMessage(hwnd, User32.WM_GETTEXT, res.intValue() + 1, windowText);

    Native.toString(windowText);

但 Native.toString(windowText) 返回“0”

4

0 回答 0