帮忙把下面这个delphi代码片段翻译成vb,分不够可以再加,急求啊。
R : longword;
P : integer;
protocol_byte : array [1..620] of byte;
rtemp_byte:array [1..4] of byte absolute R;
ptemp_byte:array [1..4] of byte absolute P;
strTemp : string; try
intFlag := -1;
fillchar(protocol_byte,sizeof(protocol_byte),0);
fillchar(rtemp_byte,sizeof(rtemp_byte),0);
fillchar(ptemp_byte,sizeof(ptemp_byte),0); P:=SArgDataReqHeader[0]; //数据类型
for i := 1 to 4 do
begin
protocol_byte[i]:=ptemp_byte[i];
end;
R:=44;
for i := 1 to 4 do
begin
protocol_byte[i+4]:=rtemp_byte[i];
end;
P:=StrToInt(SmsServer.cooperaterId); //企业编号
for i := 1 to 4 do
begin
protocol_byte[i+8]:=ptemp_byte[i];
end; if length(SmsServer.loginname) < 20 then //用户名
begin
szUserName := SmsServer.loginname + copy(strZeroTemp,1,20-length(SmsServer.loginname));
end; if length(SmsServer.ICPPass) < 16 then //密码
begin
szPassword := SmsServer.ICPPass + copy(strZeroTemp,1,16-length(SmsServer.ICPPass));
end;
strTemp := szUserName + szPassword; for i := 1 to 36 do
begin
protocol_byte[i+12]:=ord(strTemp[i]);
end; R:=1; //版本号
for i := 1 to 4 do
begin
protocol_byte[i+48]:=rtemp_byte[i];//完成消息头!
end; if not isTestMode then
begin
strMsg := '正在发送登录请求,登录验证:no:' + SmsServer.cooperaterId + ',user:' + SmsServer.loginname + ',password:' + SmsServer.ICPPass;
SmsServer.Memo1.Lines.Add(strMsg);
end;
smsServer.ClientSocket1.open; try
SmsServer.ClientSocket1.Socket.Sendbuf(protocol_byte[1],52);
intFlag := 1;
except
on e:exception do
begin
end;
end;
R : longword;
P : integer;
protocol_byte : array [1..620] of byte;
rtemp_byte:array [1..4] of byte absolute R;
ptemp_byte:array [1..4] of byte absolute P;
strTemp : string; try
intFlag := -1;
fillchar(protocol_byte,sizeof(protocol_byte),0);
fillchar(rtemp_byte,sizeof(rtemp_byte),0);
fillchar(ptemp_byte,sizeof(ptemp_byte),0); P:=SArgDataReqHeader[0]; //数据类型
for i := 1 to 4 do
begin
protocol_byte[i]:=ptemp_byte[i];
end;
R:=44;
for i := 1 to 4 do
begin
protocol_byte[i+4]:=rtemp_byte[i];
end;
P:=StrToInt(SmsServer.cooperaterId); //企业编号
for i := 1 to 4 do
begin
protocol_byte[i+8]:=ptemp_byte[i];
end; if length(SmsServer.loginname) < 20 then //用户名
begin
szUserName := SmsServer.loginname + copy(strZeroTemp,1,20-length(SmsServer.loginname));
end; if length(SmsServer.ICPPass) < 16 then //密码
begin
szPassword := SmsServer.ICPPass + copy(strZeroTemp,1,16-length(SmsServer.ICPPass));
end;
strTemp := szUserName + szPassword; for i := 1 to 36 do
begin
protocol_byte[i+12]:=ord(strTemp[i]);
end; R:=1; //版本号
for i := 1 to 4 do
begin
protocol_byte[i+48]:=rtemp_byte[i];//完成消息头!
end; if not isTestMode then
begin
strMsg := '正在发送登录请求,登录验证:no:' + SmsServer.cooperaterId + ',user:' + SmsServer.loginname + ',password:' + SmsServer.ICPPass;
SmsServer.Memo1.Lines.Add(strMsg);
end;
smsServer.ClientSocket1.open; try
SmsServer.ClientSocket1.Socket.Sendbuf(protocol_byte[1],52);
intFlag := 1;
except
on e:exception do
begin
end;
end;
Dim P as long
Dim protocol_byte(1 to 52) as byte '为了VB的Winsock控件,只能这样改
Dim strTemp as longintFlag=-1
ZeroMemory protocol_byte(1),52
R=0
P=0P=SArgDataReqHeader[0]
CopyMemory protocol_byte(1),P,4R=44
CopyMemory protocol_byte(1+4),R,4P=StrToInt(SmsServer.cooperaterId) '企业编号
CopyMemory protocol_byte(1+8),P,4if len(SmsServer.loginname) < 20 then '用户名
szUserName = SmsServer.loginname & String(20-len(SmsServer.loginname), 0)
end ifif len(SmsServer.ICPPass) < 16 then '密码
szPassword = SmsServer.loginname & String(16-len(SmsServer.ICPPass), 0)
end ifstrTemp = szUserName & szPasswordCopyMemory protocol_byte(1+12),byval strTemp,36R=1 '版本号
CopyMemory protocol_byte(1+48),R,4 '完成消息头!if not isTestMode then
strMsg = "正在发送登录请求,登录验证:no:" & SmsServer.cooperaterId & ",user:" & SmsServer.loginname & ",password:" & SmsServer.ICPPass
'SmsServer.Memo1.Lines.Add(strMsg)
with SmsServer.Memo1
.SelStart=Len(.Text)
.SelText=strMsg
.SelStart=Len(.Text)
end with
End IfsmsServer.ClientSocket1.openSmsServer.ClientSocket1.Send protocol_byteintFlag=1
SmsServer.ClientSocket1.SendData protocol_byte
(Byref dest As any, Byref source As any, ByVal bytes As Long)
Private Declare Sub ZeroMemory Lib "kernel32" Alias "RtlZeroMemory" _
(Byref dest As any, ByVal numbytes As Long)