[ComVisible(true)] [ClassInterface(ClassInterfaceType.AutoDual)] [ProgId("HelloWorld.MyClass")] //类名 public class MyClass { public string UserName { get; set; } //对外提供属性 public string SayHello(string content) //对外提供方法 { return "用户:" + this.UserName + "说:" + content; } }
类库发布设置
PB调用代码:
long ll_status string ls_errorinfo, ls_ret OLEObject myobj if not isvalid(myobj) then myobj = CREATE OLEObject end if ll_status = myobj.connecttonewobject("HelloWorld.MyClass") IF ll_status <> 0 THEN return myobj.UserName = ‘张三‘ ls_ret = myobj.SayHello("哈哈") Messagebox(‘提示‘,ls_ret)
时间: 2024-10-18 17:35:26