当前位置:网站首页>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。
边栏推荐
- [HCIA continuous update] network management and operation and maintenance
- Li Kou brush question diary /day7/2022.6.29
- 2022年全国CMMI认证补贴政策|昌旭咨询
- [cloud voice suggestion collection] cloud store renewal and upgrading: provide effective suggestions, win a large number of code beans, Huawei AI speaker 2!
- I always thought that excel and PPT could only be used for making statements until I saw this set of templates (attached)
- The controversial line of energy replenishment: will fast charging lead to reunification?
- Microservice architecture debate between radical technologists vs Project conservatives
- Achieve animation effect through event binding
- Scala基础教程--12--读写数据
- Wanghongru research group of Institute of genomics, Chinese Academy of Agricultural Sciences is cordially invited to join
猜你喜欢

Halcon模板匹配

力扣刷题日记/day7/6.30
![[cloud native] what is the](/img/00/0cb0f38bf3eb5dad02b3bc4ead36ba.jpg)
[cloud native] what is the "grid" of service grid?

爬虫(6) - 网页数据解析(2) | BeautifulSoup4在爬虫中的使用

MySQL常用增删改查操作(CRUD)

Wireshark packet capturing TLS protocol bar displays version inconsistency

uni-app与uviewUI实现仿小米商城app(附源码)

Improve the accuracy of 3D reconstruction of complex scenes | segmentation of UAV Remote Sensing Images Based on paddleseg

一直以为做报表只能用EXCEL和PPT,直到我看到了这套模板(附模板)

Stars open stores, return, return, return
随机推荐
celebrate! Kelan sundb and Zhongchuang software complete the compatibility adaptation of seven products
同事悄悄告诉我,飞书通知还能这样玩
【209】go语言的学习思想
线上MySQL的自增id用尽怎么办?
ISO27001 certification process and 2022 subsidy policy summary
MySQL common add, delete, modify and query operations (crud)
蓝桥:合根植物
ByteDance dev better technology salon was successfully held, and we joined hands with Huatai to share our experience in improving the efficiency of web research and development
.NET ORM框架HiSql实战-第二章-使用Hisql实现菜单管理(增删改查)
输入的查询SQL语句,是如何执行的?
Wireshark抓包TLS协议栏显示版本不一致问题
怎么开户才是安全的,
Once the "king of color TV", he sold pork before delisting
MySQL常用增删改查操作(CRUD)
[daily question] 871 Minimum refueling times
NBA赛事直播超清画质背后:阿里云视频云「窄带高清2.0」技术深度解读
Digital "new" operation and maintenance of energy industry
Crawler (6) - Web page data parsing (2) | the use of beautifulsoup4 in Crawlers
字节跳动Dev Better技术沙龙成功举办,携手华泰分享Web研发效能提升经验
Li Kou brush question diary /day1/2022.6.23