慕標(biāo)琳琳
2022-12-16 18:14:50
dll函數(shù)代碼如下:function BaseEncode(ss:PChar;Res:PChar):Integer;stdcall;beginStrCopy(Res,ss);StrCat(Res,'_00000');Result := StrLen(Res);end;exportsBaseEncode;調(diào)用代碼如下:function BaseEncode(ss:Pchar; Res:PChar):Integer;stdcall;external '../ChangCode/changecode.dll';procedure TForm1.Button2Click(Sender: TObject);varss:PChar;Res:PChar;Num:Integer;beginss := 'good!';Res := StrAlloc(80);Num := BaseEncode(PChar(ss), PChar(Res));Edit1.Text := Res;Edit2.Text := IntToStr(Num);StrDispose(ss);StrDispose(Res);end;但結(jié)果可以正確顯示。是這個(gè)問(wèn)題Edit1.Text := string(Res); 改了就可以。小弟一直用JAVA,DELPHI剛開(kāi)始用,謝謝啦。
1 回答
呼啦一陣風(fēng)
TA貢獻(xiàn)1802條經(jīng)驗(yàn) 獲得超6個(gè)贊
Num := BaseEncode(PChar(ss), PChar(Res));是這一行出現(xiàn)問(wèn)題嗎?試著修改為:Num := BaseEncode(ss, Res);
如果是Edit1.Text := Res;這一行,則修改為 Edit1.Text := string(Res);
你說(shuō)明白啊,哪個(gè)地方報(bào)錯(cuò)?
StrDispose, 這個(gè)你不能使用,
Description
StrDispose is provided for backward compatibility only. StrDispose disposes of a string on a heap that was previously allocated with StrAlloc or StrNew.
If Str is nil, StrDispose does nothing.需要和StrAlloc或StrNew一起使用。
去掉最后2行,就可以了。
添加回答
舉報(bào)
0/150
提交
取消
