[id(4)] HRESULT sayHello2([in] BSTR say, [out, retval] BSTR* result);
ComThread.InitMTA(true);
ActiveXComponent com = new ActiveXComponent("CLSID:FF90EFCA-0856-4159-A9CC-0E7BBC317554") ;
Dispatch disp = (Dispatch) com.getObject();
Variant a = new Variant(11);
Variant b = new Variant(2);
Variant c = new Variant();
c = Dispatch.call(disp, "Add",2,3);
System.out.println(c.toString());
Variant v = Dispatch.call(disp, "sayHello2","fuck");
System.out.println(v.toString());
Can't map name to dispid: sayHello2
ComThread.InitMTA(true);
ActiveXComponent com = new ActiveXComponent("CLSID:FF90EFCA-0856-4159-A9CC-0E7BBC317554") ;
Dispatch disp = (Dispatch) com.getObject();
Variant a = new Variant(11);
Variant b = new Variant(2);
Variant c = new Variant();
c = Dispatch.call(disp, "Add",2,3);
System.out.println(c.toString());
//用新的字符編碼生成字符串
try {
byte[] bs = "fuck".getBytes();
String xx = new String(bs, "UTF-8");
Variant v = Dispatch.call(disp, "sayHello2",xx);
System.out.println(v.toString());
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
結果正確,