delphi调用dll出现的问题

2025-02-27 02:00:44
推荐回答(4个)
回答1:

function SendSms(pSrcTermID: pchar; pDestTermID: pchar; pContent: pchar; bNeedReport: boolean; pMsgID: pchar): integer; stdcall; external 'SmgpSDK.dll' name 'SMGP_SendSms';

pMsgID: array[0..254] of char;
SendSms(..., pMsgID);
调用完后pMsgID中有你要的值了。

注意你得先确定pMsgID最长有多少字节,然后数组设置为该大小就可以了,不一定是254

回答2:

把var去掉

function SendSms(pSrcTermID: pchar; pDestTermID: pchar; pContent: pchar; bNeedReport: boolean; pMsgID: pchar): integer; stdcall; external 'SmgpSDK.dll' name 'SMGP_SendSms';

回答3:

指针本身就是一个可变的值,不变的是地址
所以没必要加var

回答4:

直接pchar