谁帮我把这段VC的代码转换成DELPHI(100分)

  • 主题发起人 主题发起人 公孙剑影
  • 开始时间 开始时间

公孙剑影

Unregistered / Unconfirmed
GUEST, unregistred user!
CString sAgentID="2206";
CString sAgentPhone="2006";
CString sComment="TMD";
BYTE bData[1024];
int ilen;
int islen;
ilen=0;

strcpy((char*)bData+ilen,"RECORD START A ");ilen+=16;

islen=sAgentID.GetLength();
memcpy(bData+ilen,&islen,2);ilen+=2;
strcpy((char*)bData+ilen,sAgentID);ilen+=islen;

islen=sAgentPhone.GetLength();
memcpy(bData+ilen,&islen,2);ilen+=2;
strcpy((char*)bData+ilen,sAgentPhone);ilen+=islen;

islen=sComment.GetLength();
memcpy(bData+ilen,&islen,2);ilen+=2;
strcpy((char*)bData+ilen,sComment);ilen+=islen;
 
const
AgentID: string = '2206';
AgentPhone: string = '2006';
Comment: string = 'TMD';
var
Data: array [0..1023] of Char;
Len, SLen: Integer;
begin
Len:=0;
StrCopy(@Data[Len], "RECORD START A ');
Inc(Len, 16);

SLen:=Length(AgentID);
CopyMemory(@Data[Len], @SLen, 2);
Inc(Len, 2);
StrCopy(@Data[Len], PChar(AgentID));
Inc(Len, SLen);



SLen:=Length(AgentPhone);
CopyMemory(@Data[Len], SLen, 2);
Inc(Len, 2);
StrCopy(@Data[Len], PChar(AgentPhone);
Inc(Len, SLen);

SLen:=Length(Comment);
CopyMemory(@Data[Len], SLen, 2);
Inc(Len, 2);
StrCopy(@Data[Len], Comment);
Inc(Len, SLen);
end;
 
sAgentID:string;
sAgentPhoen:string;
sComment:string;
bData:array[0..1023]of byte;

iLen:integer;
isLen:integer;

ilen:=0;
sAgentID:='2206';
sComment='TMD';
FillChar(bData,1024,0);
StrCopy(bData,'RECORD START A ');
inc(ilen,16);

islen:=length(sAgentID);
CopyMemory(@bData[ilen],sAgentID,isLen);
inc(ilen,islen);

islen:=length(sComment);
CopyMemory(@bData[ilen],@sComment[1],islen);
 
多人接受答案了。
 
后退
顶部