马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?站点注册
×
如何使用 pbidea 不注册 COM 直接调用 C# dll
C# dll 调用,一直是 PB 程序员的一个烧脑问题,原因在于它不能导出 PB 能识别的 WINAPI 函数,而是导出
COM 接口,因此,一般是先注册 COM,调用接口。但注册 COM 实在是不方便。
Pbidea 调用 C# dll 是相当简单,不需要注册 COM,直接调用。下面说一下步骤方法:
一、静态成员和方法
- string ls_ret
- uo_csharp cs; cs = create uo_csharp
- //加载 DLL
- if cs.load("csharpapi.dll") then
- //调用函数
- cs.invoke("pbidea", "CPbideaAPI", "dump", "test dump method")
- //取返回值
- cs.GetReturn(ls_ret)
- MsgBox("static method dump", ls_ret)
- else
- msgbox("load csharpapi.dll fail")
- end if
- destroy cs
复制代码
二、对象成员和方法
- string ls_ret
- uo_csharp cs; cs = create uo_csharp
- uo_csharp_object obj
- if cs.load("csharpapi.dll") then
- //实例化对象,然后再调用其函数
- obj = cs.CreateObject("pbidea", "CPbideaAPI")
- if isvalid(obj) then
- if obj.invoke("hello","i am text from pb", "i am title from pb", 123456.78) then
- obj.GetReturn(ref ls_ret)
- MsgBox(ls_ret)
- else
- MsgBox("invoke method hello fail")
- end if
- cs.DestroyObject(obj) //或 destroy obj
- end if
- else
- msgbox("load csharpapi.dll fail")
- end if
- destroy cs
复制代码
以上只是简单演示,更多内容请移步 pibdea demo。Demo 有强大功能。
将 C# dll 文件拖到此窗口,会自动解析出 DLL 接口信息,不需要 C#源码。
如何使用pbidea不注册COM直接调用C# dll.pdf
(257.02 KB, 下载次数: 0)
|