当前位置:网站首页>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。
边栏推荐
- LD_ LIBRARY_ Path environment variable setting
- Is it science or metaphysics to rename a listed company?
- 【系统盘转回U盘】记录系统盘转回U盘的操作
- How to improve development quality
- NBA赛事直播超清画质背后:阿里云视频云「窄带高清2.0」技术深度解读
- 表情包坑惨职场人
- Li Kou brush question diary /day1/2022.6.23
- 线上MySQL的自增id用尽怎么办?
- LD_LIBRARY_PATH 环境变量设置
- Mysql5.7 installation tutorial graphic explanation
猜你喜欢
![[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

字节跳动Dev Better技术沙龙成功举办,携手华泰分享Web研发效能提升经验

Make a grenade with 3DMAX

Unity makes revolving door, sliding door, cabinet door drawer, click the effect of automatic door opening and closing, and automatically play the sound effect (with editor extension code)

NBA赛事直播超清画质背后:阿里云视频云「窄带高清2.0」技术深度解读

力扣刷题日记/day7/2022.6.29

Wireshark packet capturing TLS protocol bar displays version inconsistency

People in the workplace with a miserable expression

华为云ModelArts的使用教程(附详细图解)

Li Kou brush question diary /day1/2022.6.23
随机推荐
力扣刷题日记/day1/2022.6.23
力扣刷题日记/day8/7.1
Russia arena data releases PostgreSQL based products
【2022年江西省研究生数学建模】水汽过饱和的核化除霾 思路分析及代码实现
爬虫(6) - 网页数据解析(2) | BeautifulSoup4在爬虫中的使用
Halcon模板匹配
输入的查询SQL语句,是如何执行的?
[HCIA continuous update] network management and operation and maintenance
MySQL常用增删改查操作(CRUD)
同事悄悄告诉我,飞书通知还能这样玩
Clever use of curl command
Lua emmylua annotation details
Interview summary of large factory Daquan II
Numpy 的仿制 2
Implementation of shell script replacement function
Li Kou brush question diary /day7/2022.6.29
mysql5.7安装教程图文详解
Redis master-slave replication
Li Kou brush question diary /day1/2022.6.23
[system disk back to U disk] record the operation of system disk back to U disk