C
coolkillerjmq
Unregistered / Unconfirmed
GUEST, unregistred user!
我现在这个程序调用前面10次能正常显示,但后面会产生几次乱码,以后就一直是空,请问这个是什么原因,在线等待,问题解决立即放分
function BalanceChar;stdcall;
var
sReadStr:String;
IdTCPClient:TIdTCPClient;
BalanceResult:String;
myIni:TIniFile;
sSoftRegCode,sSoftRegPwd:string;
sRemoteIP:string;
sPort:integer;
readstr:String;
begin
myini:=TIniFile.Create(ExtractFilePath(Application.ExeName)+'NtxSmsSet.ini');
//从ini文件中读取值
sSoftRegCode:=DeCrypt(myini.ReadString('set','sSoftRegCode',''),3);
sSoftRegPwd:=DeCrypt(myini.ReadString('set','sSoftRegPwd',''),3);
sRemoteIP:=myini.ReadString('cnconfig','RemoteIP','218.16.124.163');
sPort:=myini.ReadInteger('cnconfig','Port',9099);
myini.Free;
IdTcpClient:=TIdTcpClient.Create(Application);
try
IdTcpClient.Host:=sRemoteIP;
IdTcpClient.Port:=sPort;
if IdTCPClient.Connected=False then IdTcpClient.Connect(6000);
IdTCPClient.WriteLn('[*FB*] '+ sSoftRegCode + ' ' + sSoftRegPwd)
//向Server发送查询余额信息
sReadStr:=IdTcpClient.ReadLn
//接收查到的余额
if Copy(sReadStr,1,6)='[FBSC]' then
begin
ReadStr:=Trim(Copy(sReadStr,8,12));
if sReadStr='' then
Balanceresult:='-22'
else
Balanceresult:=ReadStr;
end
else if Copy(sReadStr,1,6)='[RCNT]' then
Balanceresult:='-22'
else
Balanceresult:='-25';
except
on E : Exception do
begin
IdTCPClient.Disconnect;
result:='-26';
exit;
end;
end;
result:=PChar(BalanceResult);
IdTCPClient.Disconnect;
end;
function BalanceChar;stdcall;
var
sReadStr:String;
IdTCPClient:TIdTCPClient;
BalanceResult:String;
myIni:TIniFile;
sSoftRegCode,sSoftRegPwd:string;
sRemoteIP:string;
sPort:integer;
readstr:String;
begin
myini:=TIniFile.Create(ExtractFilePath(Application.ExeName)+'NtxSmsSet.ini');
//从ini文件中读取值
sSoftRegCode:=DeCrypt(myini.ReadString('set','sSoftRegCode',''),3);
sSoftRegPwd:=DeCrypt(myini.ReadString('set','sSoftRegPwd',''),3);
sRemoteIP:=myini.ReadString('cnconfig','RemoteIP','218.16.124.163');
sPort:=myini.ReadInteger('cnconfig','Port',9099);
myini.Free;
IdTcpClient:=TIdTcpClient.Create(Application);
try
IdTcpClient.Host:=sRemoteIP;
IdTcpClient.Port:=sPort;
if IdTCPClient.Connected=False then IdTcpClient.Connect(6000);
IdTCPClient.WriteLn('[*FB*] '+ sSoftRegCode + ' ' + sSoftRegPwd)
//向Server发送查询余额信息
sReadStr:=IdTcpClient.ReadLn
//接收查到的余额
if Copy(sReadStr,1,6)='[FBSC]' then
begin
ReadStr:=Trim(Copy(sReadStr,8,12));
if sReadStr='' then
Balanceresult:='-22'
else
Balanceresult:=ReadStr;
end
else if Copy(sReadStr,1,6)='[RCNT]' then
Balanceresult:='-22'
else
Balanceresult:='-25';
except
on E : Exception do
begin
IdTCPClient.Disconnect;
result:='-26';
exit;
end;
end;
result:=PChar(BalanceResult);
IdTCPClient.Disconnect;
end;