tim*_*w07 6 java java-native-interface winapi swig jna
希望重新回到发展空间; 主要使用Java来调用一些原生的win32函数(我不想在.NET中构建)....
有人能指出我可以使用Java(JNI/JNA/SWIG)从不同的运行窗口读取标题的地方.假设您将知道您尝试连接的应用程序在内存空间中的位置.
在JNA:
public interface User32 extends StdCallLibrary {
User32 INSTANCE = (User32) Native.loadLibrary("user32", User32.class);
int GetWindowTextA(PointerType hWnd, byte[] lpString, int nMaxCount);
}
Run Code Online (Sandbox Code Playgroud)
要使用它:
byte[] windowText = new byte[512];
PointerType hwnd = ... // assign the window handle here.
User32.INSTANCE.GetWindowTextA(hwnd, windowText, 512);
System.out.println(Native.toString(windowText));
Run Code Online (Sandbox Code Playgroud)
您可能希望为HWND使用正确的结构映射,并允许unicode支持; 您可以在JNA网站上找到有关如何做到这一点的信息和更多示例.
GetWindowText函数的文档可在MSDN中找到.
有关JNA的文档,请访问jna.dev.java.net