C#例子的全部代码如下:
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace test2
{
public class test2
{
public int ShowMsg(out int a1,out string a2)
{
a1 = 200;
a2 = "message";
return 100;
}
}
}
PB调用的方法如下:
OLEObject test2
long ll_status
integer li_return
long ll_a1
string ls_a2
//创建OLEObject对象
test2 = Create OLEObject
ll_status= test2.ConnectToNewObject("test2.test2")
if ll_status=0 then
//调用类内的公共函数
li_return = test2.ShowMsg(ref ll_a1,ref ls_a2)
messagebox(string(ll_a1)+" "+ls_a2,string(li_return))
end if
//释放资源
test2.DisConnectObject()
特别说明:
ll_status= test2.ConnectToNewObject("test2.test2")语句中的两个test2,前一个是C#的命名空间,后一个是类的名称。