using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Runtime.InteropServices; namespace TestCom { [Guid("E9BCF867-CD81-40d0-9591-ED28D1ED2B53")] public interface IEncrypt { [DispId(1)] string GetEncrypt(string str,string str2); } [Guid("33A6E58D-E1F5-4b53-B2E2-03B9F8BA2FAD"), ClassInterface(ClassInterfaceType.None)] public class Encrypt:IEncrypt { public Encrypt(){} public string GetEncrypt(string str,string str2) { return "测试 | "+str+"|"+str2; } } } |
import com.jacob.activeX.ActiveXComponent; import com.jacob.com.ComThread; import com.jacob.com.Dispatch; import com.jacob.com.Variant; public class test { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub try{ ActiveXComponent dotnetCom = null; dotnetCom = new ActiveXComponent("TestCom.Encrypt"); Variant var = Dispatch.call(dotnetCom,"GetEncrypt","哥是第一个参数","哥是第二个参数"); String str = var.toString(); //返回值 } catch (Exception ex) { ex.printStackTrace(); } } } |
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) | 黑马程序员IT技术论坛 X3.2 |