Java中调用Windows API的方法
linux-dash
A beautiful web dashboard for Linux
项目地址:https://gitcode.com/gh_mirrors/li/linux-dash

·
要在Java中调用Windows API,最简单的方法就是使用JNative.jar中提供的接口。该库已经对Linux和Windows系统中的API进行了封装,
例如对Windows,使用它里面的接口调用就和在Delphi等开发工具中的调用方法是一样的,因为函数的名字和参数都是一样的。下面说明其用法。
安装方法:将JNative.jar加到classpath中即可。
假如现在要给QQ的窗口发送消息,程序如下:
import org.junit.Test;
import org.xvolks.jnative.misc.basicStructures.HWND;
import org.xvolks.jnative.misc.basicStructures.LPARAM;
import org.xvolks.jnative.misc.basicStructures.UINT;
import org.xvolks.jnative.misc.basicStructures.WPARAM;
import org.xvolks.jnative.util.User32;
public class JNativeLearning {
@Test
public void sendMessage() throws Exception{
HWND hWnd = User32.FindWindow("TXGuiFoundation", "QQ2010");
if(hWnd.getValue()>0){
System.out.println("window exists");
User32.SendMessage(hWnd, new UINT(0x10), new WPARAM(0), new LPARAM(0));
}else{
System.out.println("window doesn't exists");
}
}
}
其它接口请参见其JavaDoc:http://jnative.free.fr/docs/
转载: http://qujianfeng.iteye.com/blog/1258363




A beautiful web dashboard for Linux
最近提交(Master分支:5 个月前 )
186a802e
added ecosystem file for PM2 4 年前
5def40a3
Add host customization support for the NodeJS version 4 年前
更多推荐
所有评论(0)