[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 myobjif not isvalid(myobj) thenmyobj = CREATE OLEObject
end ifll_status = myobj.connecttonewobject("HelloWorld.MyClass")IF ll_status <> 0 THEN returnmyobj.UserName = '张三'
ls_ret = myobj.SayHello("哈哈")
Messagebox('提示',ls_ret)