740
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace PB_tests
{
[Guid("B3798F4F-A0FF-4833-945A-C7BF140ADF1A")] //利用GUID生成器随机生成,大家上网查如何生成,必须
public interface CallParamers
{
[DispId(1)]
string PBCall(string para, ref int result);
}
[ComVisible(true)]
[Guid("0EA797E2-4472-4B30-A11D-1F7302B874C1")] //利用GUID生成器随机生成,大家上网查如何生成,必须
[ClassInterface(ClassInterfaceType.None)]
public class Class1 : CallParamers
{
public string PBCall(string para, ref int result)
{
result = 1234;
char[] tmp = para.ToCharArray();
Array.Reverse(tmp);
return new string(tmp);
}
public static void Main(string[] args)
{
}
}
}
string messages
string test = "asd123"
int flag, returns
OleObject Oleb
Oleb = Create OLEObject
flag = Oleb.ConnectToNewObject("PB_tests.Class1") //CallByPB为C#中命名空间(namespace) ,Class1为C#中类名
if flag <> 0 then
MessageBox("提示", string(flag)+" PB调用C#COM组件失败,返回消息")
return
end if
messages =Oleb.PBCall(test, ref returns)
MessageBox("提示", messages+'~n'+string(returns))
楼主,我也碰到这样的情况,请问你解决了吗