前几天写的动态库遇到个新问题,当动态库参数为结构体时,程序不能调用,一调用就崩掉。经过向群里大侠请教,最后终于解决。
powerbasic中传递字符串用ASCIIZ*N 定长字符串时powerbuilder用character abc[n] 接收
powerbasic中传递指针时 dim str_prt asciiz prt powerbuilder用 string 接收
powerbasic定义结构如下时
TYPE mytype
str_name AS ASCIIZ PTR
str_id AS ASCIIZ PTR
END TYPE
FUNCTION Mystr STDCALL ALIAS "Mystr" (BYREF Param1 AS mytype) EXPORT AS STRING
Param1.@str_name= "zhangsan"
?Param1.@str_id ="1234567"
FUNCTION = "1"
END FUNCTION
pb中声明及调用如下
global type mytype from structure string str_name string str_id end type
函数声明:
Function string Mystr( ref mytype Mystra ) library "mydll.dll"alias for "Mystr"
函数调用
mytype my_yhm
messagebox(‘‘,‘调用函数前‘,Exclamation!)
ls_regist = Mystr(my_yhm)
messagebox(‘‘,my_yhm.str_user,Exclamation!)
原文:http://www.cnblogs.com/mybuilder/p/4335479.html