首页 > 代码库 > PowerBuilder调用.Net编译好的DLL
PowerBuilder调用.Net编译好的DLL
C#代码-----------------------------------------------------------------
[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;
}
}
Visaul Studio项目属性设置----------------------------------------
PowerBuilder代码-----------------------------------------------------------------
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)
PowerBuilder调用.Net编译好的DLL