【转】java jawin api 中文 invoke方法
org.jawin
Class FuncPtr
java.lang.Object
org.jawin.FuncPtr
--------------------------------------------------------------------------------
public final class FuncPtr
extends java.lang.Object
这个是用来调用标准DLL的类
Class
for working with a reference to a single Win32 function exposed in
standard DLL's. The Jawin Userguide - Calling a DLL Entry Point
这个文档可以当作如何使用JAWIN的参考
document should be consulted about how to use this class.
包括了一些常用的函数的调用方法
Contains several invoke_*-methods for some standard function signatures.
可以大概分成一下三种
These falls in three groups:
invoke_I- 一些以INT做为标准返回的本地方法的调用函数
methods for native methods with a standard int as [retval]
invoke_OI-一些最后参数作为[out]返回的本地方法的调用函数
methods for native methods with a last parameter being a [out] int
invoke_S-一些返回数组的本地方法的调用函数(也可以被使用那些返回为STRUCTS的方法)
methods for native methods returning a byte array (can be used for methods returning structs)
Please
notice that because of the TYPEDEF in C/C++ many method signatures are
covered by the relatively few invoke_*-methods, as eg. HWND, HRESULT,
LONG etc. all can be represented as Java int's.
请注意C/C++的返回信息的类型和JAVA不同,但是有一些类型可以用java的一些类型代替
比图 HWND,HRRSULT LONG等等 这些都能被表示成为java的int
If
working with a function that does not match one of the standard
signatures, use the generic invoke(String, int, NakedByteStream,
Object[], ReturnFlags).
如果使用的一些函数不能和标准的调用方法不匹配,请使用标准的调用方法
Version:
版本 1.3
$Revision: 1.3 $
Author:
作者:
Stuart Halloway, http://www.relevancellc.com/halloway/weblog/
Morten Andersen, arosii_moa (at) users.sourceforge.net
See Also:
例子:
The Jawin Userguide - Calling a DLL Entry Point
--------------------------------------------------------------------------------
Constructor Summary构造器描述
FuncPtr(java.lang.String dll, java.lang.String name)
? Method Summary
void close()
Call to "free" the function pointer. 释放函数指针
boolean equals(java.lang.Object o)
protected void finalize()
backup for releasing resources, by calling close().备份被释放的资源
int getPeer()
int hashCode()
int invoke_I(byte[] arg0, ReturnFlags flags)
调用需要一个数组指针作为参数的本地方法,返回整形变量
for calling native methods taking one pointer to a byte array, and returning an int.
int invoke_I(int arg0, int arg1, int arg2, int arg3, ReturnFlags flags)
返回需要四个整形变量作为参数的本 地方法,返回一个整形变量
for calling native methods taking four int args, and returning an int.
int invoke_I(int arg0, int arg1, ReturnFlags flags)
调用以两个整形变量作为参数的本地方法,返回一个整形变量
for calling native methods taking two int args, and returning an int.
int invoke_I(int arg0, ReturnFlags flags)
调用以一个整形变量作为参数的本地方法,返回一个整形变量
for calling native methods taking one int arg, and returning an int.
int invoke_I(int arg0, java.lang.String arg1, ReturnFlags flags)
调用以一个整形变量和以个字符串变量为参数的本地方法,返回一个整形变量
for calling native methods taking one int and one String args, and returning an int.
int invoke_I(int arg0, java.lang.String arg1, java.lang.String arg2, int arg3, ReturnFlags flags)
调用以一个整形变量和两个字符串变量和一个整形变量作为参数的本地方法,返回一个整形变量(使用MessageBoxWDEMO的例子)
for calling native methods taking one int, two String and one int args, and returning an int (used for MessageBoxW).
int invoke_I(ReturnFlags flags)
调用没有变量的本地方法,返回一个整形变量
for calling native methods taking no args, and returning an int.
int invoke_I(java.lang.String arg0, ReturnFlags flags)
调用以一个字符串作为参数的本地方法,返回一个整形变量
for calling native methods taking one String arg, and returning an int.
int invoke_I(java.lang.String arg0, java.lang.String arg1, ReturnFlags flags)
调用以两个字符串变量的本地方法,返回一个整形变量
for calling native methods taking two String args, and returning an int.
int invoke_OI(int arg0, int arg1, int arg2, int arg3, ReturnFlags flags)
调用以五个整形变量,其中前面四个作为[IN]参数,最后一个作为[OUT]变量的本地方法
for calling native methods taking five int args, where the first four
are standard [in] parameters and the last int is a [out] parameter.
int invoke_OI(int arg0, ReturnFlags flags)
调用以两个整形变量,其中最后个整形变量作为[OUT]变量 作为参数的本地方法,
for calling native methods taking two int args, where the last int is a [out] parameter.
int invoke_OI(int arg0, java.lang.String arg1, ReturnFlags flags)
调用以一个整形变量作为[IN]参数,一个字符串类型作为[OUT]参数的本地方法,返回一个整形
for calling native methods taking one [in] int, one [in] String and one [out] int arg.
byte[] invoke_S(byte[] arg0, int arg1, int returnSize, ReturnFlags flags)
调用以一个数组指针一个整形变量作为参数的本地方法,返回一个制定大小的BYTE数组
for calling native methods taking one pointer to a byte array and one
int args, and returning a byte array of a specified size.
byte[] invoke_S(byte[] arg0, int returnSize, ReturnFlags flags)
调用以一个数组指针作为参数的本地方法,返回一个指定大小的byte数组
for calling native methods taking one pointer to a byte array, and returning a byte array of a specified size.
byte[] invoke_S(int arg0, int returnSize, ReturnFlags flags)
调用以一个整形变量作为参数的本地方法,返回一个指定大小的BYTE数组(一般用于返回以个已知大小的STRUCT的情况)
for calling native methods taking one int arg, and returning a byte
array of a specified size (typically used when calling methods returning
a struct with a known byte-size).
byte[] invoke(java.lang.String
instructions, int stackSize, int argStreamSize, byte[] argStream,
java.lang.Object[] objectArgs, ReturnFlags flags)
调用那些不匹配invoke_*调用方法的本地方法
generic method for calling native methods that do not match any of the invoke_* methods.
byte[]
invoke(java.lang.String instructions, int stackSize, NakedByteStream
argStream, java.lang.Object[] objectArgs, ReturnFlags flags)
一种调用使用了NakedByteStream构造输入参数流的invoke(String, int, int, byte[], Object[], ReturnFlags) 的快捷方法
shortcut method for calling invoke(String, int, int, byte[], Object[],
ReturnFlags) when using a NakedByteStream for building the
argStream-bytes.
java.lang.String toString()
Methods inherited from class java.lang.Object这些方法继承了ava.lang.Object
clone, getClass, notify, notifyAll, wait, wait, wait
?
Constructor Detail
FuncPtr
public FuncPtr(java.lang.String dll,
java.lang.String name)
throws COMExceptionParameters:
参数:
dll - DLL动态库的名称(可以是只有名字的DLL动态库或者是完全地址的名字DLL动态库,注释,文件的后缀不是一定需要的准确的参数语法可以再MSDN文档库里找到
the
name of a DLL (can be either just the name of the DLL or a full path -
use backslashes (\)). Note, that the name is not case sensitive and that
the ".dll"-part is optional. The exact syntax for the parameter can be
found in the MSDN documentation for LoadLibrary.
name - DLL动态库中可被见的本地方法
the function name exposed in the DLL.
Throws:
COMException - 当不能连接到DLL动态库或者找不到方法会发出错误
if unable to load the DLL or find the function.
java.lang.NullPointerException - 当DLL动态库的名字是空会发出的错误
if either dll or name is null.