java通过JNative 调用delphi Pointer无法解析

delphi代码

function test3(var ss: PChar): integer stdcall;
begin
  ss := '返回3';
  Result := 123456;
end;


JAVA代码:
import org.xvolks.jnative.JNative;
import org.xvolks.jnative.Type;
import org.xvolks.jnative.exceptions.NativeException;
import org.xvolks.jnative.misc.basicStructures.AbstractBasicData;
import org.xvolks.jnative.pointers.Pointer;
import org.xvolks.jnative.pointers.memory.MemoryBlockFactory;

public class SystemTime extends AbstractBasicData<SystemTime>{

	 
	 public String ss;

    /**
     * 分配内存,并返回指针
     */
    public Pointer createPointer() throws NativeException {
        pointer = new Pointer(MemoryBlockFactory.createMemoryBlock(getSizeOf()));
        return pointer;
    }

    /**
     * 内存大小
     */
    public int getSizeOf(){
        return 1024;
    }

    /**
     * 获取通过内存指针解析出结果
     */
    public SystemTime getValueFromPointer() throws NativeException {

    	ss = getNextShort()+"" ;
        return this;
    }

    public SystemTime() throws NativeException{
        super(null);
        createPointer();
    }

    public String toString(){
       
    	return ss+"";
    }

    public static SystemTime GetSystemTime() throws NativeException, IllegalAccessException {
        // 创建对象
        JNative jn = new JNative("C:/testdll/dlltest.dll", "test3");
        jn.setRetVal(Type.INT);
        SystemTime systemTime = new SystemTime();
        // 设置参数
        jn.setParameter(0, systemTime.getPointer());
        jn.invoke();
        // 解析结构指针内容
       
        return systemTime.getValueFromPointer();
    }

    public static void main(String[] args) throws NativeException, IllegalAccessException{
        System.err.println(GetSystemTime());
        
    }

}



获取var ss: PChar  ,ss := '返回3' 一直不能获取到,可以得到内存地址,但是地址里不知道怎么获得值,请前辈们帮忙提解一下,谢谢了。

你可能感兴趣的:(java,C++,c,C#,Delphi)