|
http://bbs.2ccc.com/topic.asp?topicid=496558
大家可以看看这个帖子。
调用 DLL。也可以使用 TEncoding
function GetVerifyCode(fileName: PByte; strsn: PByte; var strCode: PByte): BOOL; stdcall; external 'GetVerifyCode.dll';
procedure TForm1.Button1Click(Sender: TObject);
var
aFile, aSn, aCode: string;
PFile,PSn, PCode: PByte;
ACodes: TBytes;
begin
aFile := 'verify_code.bin';
aSn := '535727843';
PFile := addr(TEncoding.ANSI.GetBytes(aFile)[0]); //建议 GetBytes(aFile + #0)
PSn := addr(TEncoding.ANSI.GetBytes(aSn)[0]); //建议 GetBytes(aSn + #0)
SetLength(ACodes, 6); //ANSI 是 6 Unicode 是 6*2。//建议多留一个字符的空间,用于存放 #0
PCode := addr(ACodes[0]);
if GetVerifyCode(PFile, PSn, PCode) then
begin
aCode := TEncoding.ANSI.GetString(ACodes);
ShowMessage(aCode);
end
else
begin
ShowMessage('获取密码失败!');
end;
end; |
|