PB 使用SMS.DLL在PB中调用时,发现返回值为乱码。
推测异常原因可能是: DLL中定义的数据类型与PB数据类型不同造成。
使用DELPHI调用相同的DLL,返回值正常。
//DLL声明
function uint Sms_Connection(string CopyRight,uint Com_Port,uint Com_BaudRate,ref string Mobile_Type,ref string CopyRightToCOM)library "sms.dll" alias for "Sms_Connection;Ansi"
//PB代码
integer li_com,li_rc
string ls_type
string str_copyright
string str_copyrighttocom
ls_type = space(5000)
str_CopyRight='//上海迅赛信息技术有限公司,网址www.xunsai.com//'
if ddlb_com.text = '' or isnull(ddlb_com.text) then
messagebox('','连接不能为空!')
return
end if
li_com = integer(ddlb_com.text)
li_rc = sms_connection(str_copyright,li_com,9600,ls_type,str_copyrighttocom)
if li_rc > 0 then
st_mobile.text = string(ls_type)
messagebox(string(len(trim(ls_type))),trim(ls_type))
messagebox('','连接成功!')
cb_1.enabled = false
cb_2.enabled = true
else
messagebox('','连接失败!')
cb_1.enabled = true
cb_2.enabled = false
end if