-
https://github.com/matthiasblaesing/COMTypelibraries
pom配置:
eu.doppel-helix.jna.tlbcodegenerator TlbCodeGenerator 1.0.2 D:/BackUp/op/op-0.4.0/op_x86.dll从项目文件夹运行执行
mvn eu.doppel-helix.jna.tlbcodegenerator:TlbCodeGenerator:generate
生成代码 调用方法:IOpInterface op = new Factory().createObject(OpInterface.class); System.out.println(op.Ver());
-
先注册dll 后执行,需要知道tlb.id,查看这个id可以用 ResourceHacker 查看
java -cp "jna.jar;jna-platform.jar" com.sun.jna.platform.win32.COM.tlb.TlbImp -tlb.id {66b9c175-82f2-45e9-af86-58ad5ded5adc} -tlb.major.version 1 -tlb.minor.version 0 -bind.mode dispId -output.dir outputdir
调用方法:
Ole32.INSTANCE.CoInitializeEx(Pointer.NULL, Ole32.COINIT_MULTITHREADED); OpInterface2 op2 = new OpInterface2(); System.out.println("demo2: " + op2.Ver());
demo是针对OP做的