更新时间:2023-12-03 23:36:52
在JNA中:
public interface User32 extends StdCallLibrary {
User32 INSTANCE = (User32) Native.loadLibrary("user32", User32.class);
int GetWindowTextA(PointerType hWnd, byte[] lpString, int nMaxCount);
}
使用它:
byte[] windowText = new byte[512];
PointerType hwnd = ... // assign the window handle here.
User32.INSTANCE.GetWindowTextA(hwnd, windowText, 512);
System.out.println(Native.toString(windowText));
您可能希望为HWND使用正确的结构映射,并允许unicode支持;您可以在 JNA网站上找到有关如何操作的信息和更多示例。
You'll probably want to use the proper structure mappings for HWND and also allow unicode support; you can find that information and more examples on how to do that at the JNA website.
GetWindowText函数的文档可在 MSDN 。
The documentation for GetWindowText function is available here in MSDN.
JNA的文档位于 jna.dev.java.net