当前位置:网站首页>PB的扩展DLL开发(超级篇)(七)
PB的扩展DLL开发(超级篇)(七)
2022-07-04 17:05:00 【lxbin2003】
PB的扩展DLL开发(超级篇)(七)
(PB史上第一次开放的开发技术)
对象实例化与销毁
假设有PB代码是这样:
uo_json js
js = create uo_json
DLL里实现同样的功能代码是:
OB_INST_ID obInstID = NULL;
if (rt_create_obinst(obThis, (LPTSTR)_T(“uo_json”), &obInstID) == 1)
{
//实例化成功
}
如果要把实例返回给PB
OB_DATA obReturn = {0};
OB_CLASS_HNDL hndl = ob_get_obinst_class_hndl(obThis, obInstID);
OB_CLASS_ID classID = hndl.class_id ; //得到其类型
ob_set_data_obinst(&obReturn, obInstID, classID, OB_INSTVAR_FIELD);
if(obInstID == NULL)
ob_set_info_nullval(obReturn .info, TRUE); //如果创建失败,是空值,要把NULL标志打上,这样在PB里用 isnull() 或 isvalid() 判断时会是 false
ot_set_return_val(obThis, &obReturn); //返回对象实例
其他可以对象实例化的函数还有:
ob_create_obinst
ot_create_obinst_with_name
ot_create_obinst_at_lval
ob_create_object
ob_create_object_using
有ot_开头的和ob_开头的函数,ot_开头的应该是runtime 类函数,比ob_开头要高级一些,建议尽量使用 ot_开头的函数。
一个对象实例后,返回给PB环境,可以显式的 destroy js,如果不写destroy代码,PB也会自动 销毁它。
DLL里可以自己销毁
ob_destroy_obinst(obThis,obInstID);
要注意, PB代码里并不知道你DLL里已销毁,会继续销毁,造成程序崩溃。所以,通常不需要调用ob_destroy_obinst这个销毁函数。
我在思考:这个销毁导致崩溃,应该跟引用计数有关系。只有当它的引用计数为0时,才会真正销毁。有个函数 rtDataCopy它的最后一个参数表示是否增加引用计数。如果是传入参数,我们可以用 rtDataCopy 复制一份自己用,用完可以ob_destroy_obinst,不会崩溃。可惜,我没找到在哪可以直接添加这个引用计数。有知道的请告诉我一下,我好把这个坑填一下。(*(DWORD*)((DWORD)obInstID + 24)) ++; 倒是可以实现计数增1,但总不敢用,还是有SDK 函数用起来更放心。
以上说的是不可视对象和实例化和销毁。至于可视化对象,还是在PB设计环境里用鼠标拖放吧,DLL里实现起来非常复杂,我也没掌握好,这里就不说了。
如果你对system library相关开发方式感兴趣,可到QQ群624409252共享里大自在的专用目录下下载DEMO。
边栏推荐
- Li Kou brush question diary /day1/2022.6.23
- [210] usage of PHP delimiter
- Is it science or metaphysics to rename a listed company?
- How is the entered query SQL statement executed?
- Numpy 的仿制 2
- 机器学习概念漂移检测方法(Aporia)
- Thawte通配符SSL证书提供的类型有哪些
- Load test practice of pingcode performance test
- MySQL常用增删改查操作(CRUD)
- TorchDrug教程
猜你喜欢

"In Vietnam, money is like lying on the street"

How is the entered query SQL statement executed?

Li Kou brush question diary /day3/2022.6.25

Installation and use of VMware Tools and open VM tools: solve the problems of incomplete screen and unable to transfer files of virtual machines

Is it science or metaphysics to rename a listed company?

People in the workplace with a miserable expression
![[2022 Jiangxi graduate mathematical modeling] curling movement idea analysis and code implementation](/img/63/8d5f875b4409511628faf2914836d3.png)
[2022 Jiangxi graduate mathematical modeling] curling movement idea analysis and code implementation

1、 Introduction to C language

Neglected problem: test environment configuration management

Wireshark packet capturing TLS protocol bar displays version inconsistency
随机推荐
Neglected problem: test environment configuration management
蓝桥:合根植物
一直以为做报表只能用EXCEL和PPT,直到我看到了这套模板(附模板)
Scala基础教程--15--递归
Make a grenade with 3DMAX
DB engines database ranking in July 2022: Microsoft SQL Server rose sharply, Oracle fell sharply
Scala基础教程--12--读写数据
What types of Thawte wildcard SSL certificates provide
【210】PHP 定界符的用法
Stars open stores, return, return, return
【Hot100】31. Next spread
[cloud native] what is the "grid" of service grid?
Journal des problèmes de brosse à boutons de force / day6 / 6.28
mysql5.7安装教程图文详解
爬虫(6) - 网页数据解析(2) | BeautifulSoup4在爬虫中的使用
Lua emmylua annotation details
[daily question] 871 Minimum refueling times
Installation and use of VMware Tools and open VM tools: solve the problems of incomplete screen and unable to transfer files of virtual machines
用于图数据库的开源 PostgreSQL 扩展 AGE被宣布为 Apache 软件基金会顶级项目
LD_LIBRARY_PATH 环境变量设置