1. 程式人生 > >貼上 JNA—JNI 終結者 、 深入解析 JNA— 模擬 C 語言結構體 兩篇文章的完整原始碼 (續)...

貼上 JNA—JNI 終結者 、 深入解析 JNA— 模擬 C 語言結構體 兩篇文章的完整原始碼 (續)...

原文 http://blog.csdn.net/shendl/archive/2008/12/26/3599854.aspx

/**

* @param args

*/

public static void main(String[] args) {

// TODO Auto-generated method stub

TestDll1. INSTANCE .say( new WString( "Hello World!" ));

System. out .println( "HHEEH 我我們無法萬惡 " );

UserStruct.ByReference userStruct=

new UserStruct.ByReference();

userStruct. id = new NativeLong(100);

userStruct. age =30;

userStruct. name = new WString( " 沈東良 " );

TestDll1. INSTANCE .sayUser(userStruct);

System. out .println( "AAAAAAAAAAAAAAAAAAAAAAAAAAA" );

CompanyStruct.ByReference companyStruct= new CompanyStruct.ByReference();

companyStruct. id = new NativeLong(1);

companyStruct. name = new WString( "Google" );

companyStruct. count =9;

companyStruct. users = new UserStruct.ByValue[100];

//companyStruct.users=(UserStruct[])new UserStruct().toArray(100);

UserStruct.ByValue userStructValue= new UserStruct.ByValue();

userStructValue. id = new NativeLong(100);

userStructValue. age =30;

userStructValue. name = new WString( " 沈東良 " );

for ( int i=0;i<companyStruct. count ;i++){

companyStruct. users [i]=userStructValue;

//companyStruct.users[i].id=new NativeLong(companyStruct.users[i].id.intValue()+i);

}

TestDll1. INSTANCE .sayCompany(companyStruct);

/*

System.out.println ("++++++++++++++");

UserStruct.ByReference pUserStruct=new UserStruct.ByReference();

pUserStruct.id=new NativeLong(90);

pUserStruct.age=99;

pUserStruct.name=new WString(" 良少 ");

TestDll1.INSTANCE.sayUser(pUserStruct);

System.out.println ("---------------------");

UserStruct.ByValue userStructValue=new UserStruct.ByValue();

userStructValue.age=10;

userStructValue.id=new NativeLong(1);

userStructValue.name=new WString(" 良子 ");

TestDll1.INSTANCE.sayUser(userStructValue);

*/

System. out .println( "BBBBBBBBBBBBBBBBBBBBBBBB" );

CompanyStruct2.ByReference companyStruct2= new CompanyStruct2.ByReference();

companyStruct2. id = new NativeLong(2);

companyStruct2. name = new WString( "Yahoo" );

companyStruct2. count =10;

UserStruct.ByReference pUserStruct= new UserStruct.ByReference();

pUserStruct. id = new NativeLong(90);

pUserStruct. age =99;

pUserStruct. name = new WString( " 良少 " );

pUserStruct.write();

// TestDll1.INSTANCE.sayUser(pUserStruct);

for ( int i=0;i<companyStruct2. count ;i++){

companyStruct2. users [i]=pUserStruct;

//companyStruct.users[i].id=new NativeLong(companyStruct.users[i].id.intValue()+i);

}

TestDll1. INSTANCE .sayCompany2(companyStruct2);

}

}