各位大虾:
请多关照!!!!,原代码呈上。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ScktComp, ComCtrls, Menus, ExtCtrls;
type
//开户请求
pzjyh=^msgaddsubreq;
msgaddsubreq= packed record
msgcominfo_t: packed Record
devent:smallint;
dlen :smallint;
dnods :smallint;
dserverid:smallint
end ;
msgoperator_t
acked record
id:smallint;
name:array[1..11] of char;
passsmallint:array[1..9] of char
end;
msgsub_info_t
acked record
sub_isdn:array[1..21] of char;
sub_name:array[1..21] of char;
sm_allowed:byte;
chinese_support:byte
end;
end;
//销户请求
pjsyh=^msgdelsubreq;
msgdelsubreq= packed record
msgcominfo_t: packed Record
devent:smallint;
dlen :smallint;
dnods :smallint;
dserverid:smallint
end ;
msgoperator_t
acked record
id:smallint;
name:array[1..11] of char;
passsmallint:array[1..9] of char
end;
msgsub_info_t
acked record
sub_isdn:array[1..21] of char
end;
end;
//返回信息
pans=^msganser;
msganser=packed record
msgcominfo_t: packed Record
devent:smallint;
dlen :smallint;
dnods :smallint;
dserverid:smallint
end ;
msganser: packed record
bresult:byte;
errtype:smallint
end;
end;
TForm1 = class(TForm)
StatusBar1: TStatusBar;
ClientSocket1: TClientSocket;
Memo1: TMemo;
Memo2: TMemo;
MainMenu1: TMainMenu;
client1: TMenuItem;
connect1: TMenuItem;
disconnect1: TMenuItem;
N1: TMenuItem;
quit1: TMenuItem;
Button1: TButton;
Timer1: TTimer;
Animate1: TAnimate;
procedure quit1Click(Sender: TObject);
procedure connect1Click(Sender: TObject);
procedure disconnect1Click(Sender: TObject);
procedure ClientSocket1Connect(Sender: TObject;
Socket: TCustomWinSocket);
procedure ClientSocket1Disconnect(Sender: TObject;
Socket: TCustomWinSocket);
procedure Button1Click(Sender: TObject);
procedure ClientSocket1Read(Sender: TObject; Socket: TCustomWinSocket);
procedure ClientSocket1Connecting(Sender: TObject;
Socket: TCustomWinSocket);
procedure ClientSocket1Error(Sender: TObject; Socket: TCustomWinSocket;
ErrorEvent: TErrorEvent; var ErrorCode: Integer);
procedure ClientSocket1Lookup(Sender: TObject;
Socket: TCustomWinSocket);
private
{ Private declarations }
public
{ Public declarations }
addr:string;
flag :integer;
end;
var
Form1: TForm1;
aaa
zjyh;
bbb
jsyh;
answer
ans;
buf:array[1..1000] of char;
buf1:array[1..1000] of char;
cczlx:array[1..2] of char;
dhhm
acked array[1..11] of char;
i, kkk:integer;
implementation
{$R *.DFM}
procedure TForm1.quit1Click(Sender: TObject);
begin
clientsocket1.active:=false;
dispose(aaa);
dispose(bbb);
dispose(answer);
close;
end;
procedure TForm1.connect1Click(Sender: TObject);
begin
kkk:=1;
if clientsocket1.active then
clientsocket1.active:=false;
//if inputquery('connect to computer', 'ip address',addr) then
// begin
with clientsocket1 do
begin
address:='214.160.1.200';
Active:=True;
statusbar1.panels[0].text:='connecting to '+addr+'...';
// end;
end;
new(aaa);
new(bbb);
new(answer);
//------将判断标志初始化-------------
flag:=0;
cczlx:='EN'
//-------------------
end;
procedure TForm1.disconnect1Click(Sender: TObject);
begin
clientsocket1.active:=false;
statusbar1.panels[0].text:='';
end;
procedure TForm1.ClientSocket1Connect(Sender: TObject;
Socket: TCustomWinSocket);
begin
statusbar1.Panels[0].text:='当前连接对象:'+' 短消息服务中心';
end;
procedure TForm1.ClientSocket1Disconnect(Sender: TObject;
Socket: TCustomWinSocket);
begin
statusbar1.panels[0].text:=socket.remoteaddress+'disconnect';
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if cczlx='EN' then
begin
aaa^.msgcominfo_t.devent:=20105;
aaa^.msgcominfo_t.dlen:=66 ;
aaa^.msgcominfo_t.dnods:=201;
aaa^.msgcominfo_t.dserverid :=210;
aaa^.msgoperator_t.id:=101;
aaa^.msgoperator_t.name :='88888888888';
aaa^.msgoperator_t.passsmallint :='1234567'+char(0)+char(0);
aaa^.msgsub_info_t.sub_isdn:='8613972115216'+char(0)+char(0)+char(0)+char(0)+char(0)+char(0)+char(0)+char(0);
for i:=3 to 13 do
dhhm[i-2]:=aaa^.msgsub_info_t.sub_isdn
;
aaa^.msgsub_info_t.sub_name:='999999999999999999999';
aaa^.msgsub_info_t.sm_allowed :=1;
aaa^.msgsub_info_t.chinese_support:=1;
move(aaa^,buf,sizeof(msgaddsubreq));
clientsocket1.socket.sendbuf(buf,1000) ;
//repeat
//kkk:=kkk+1;
//until flag=1
end
else
begin
bbb^.msgcominfo_t.devent:=20135;
bbb^.msgcominfo_t.dlen:=43 ;
bbb^.msgcominfo_t.dnods:=201;
bbb^.msgcominfo_t.dserverid :=210;
bbb^.msgoperator_t.id:=101;
bbb^.msgoperator_t.name :='88888888888';
bbb^.msgoperator_t.passsmallint :='1234567'+char(0)+char(0);
bbb^.msgsub_info_t.sub_isdn:='8613508610459'+char(0)+char(0)+char(0)+char(0)+char(0)+char(0)+char(0)+char(0);
dhhm[i-2]:=aaa^.msgsub_info_t.sub_isdn;
move(bbb^,buf,sizeof(msgaddsubreq));
clientsocket1.socket.sendbuf(buf,1000);
//repeat
//kkk:=kkk+1;
//until flag=2
end
end;
procedure TForm1.ClientSocket1Read(Sender: TObject;
Socket: TCustomWinSocket);
begin
flag:=0;
clientsocket1.socket.receivebuf(buf1,1000);
move(buf1,answer^,sizeof(answer^));
memo2.lines.add(inttostr(integer(answer^.msgcominfo_t.devent)));
memo2.lines.add(inttostr(integer(answer^.msgcominfo_t.dlen)));
memo2.lines.add(inttostr(integer(answer^.msgcominfo_t.dnods)));
memo2.lines.add(inttostr(integer(answer^.msgcominfo_t.dserverid))) ;
memo2.lines.add(inttostr(integer(answer^.msganser.bresult))) ;
memo2.lines.add(inttostr(integer(answer^.msganser.errtype))) ;
// if integer(answer^.msgcominfo_t.devent)=20110 then
// flag:=1;
// if integer(answer^.msgcominfo_t.devent)=20140 then
// flag:=2;
kkk:=kkk+1 ;
memo2.lines.add(inttostr(integer(kkk)))
end;
procedure TForm1.ClientSocket1Connecting(Sender: TObject;
Socket: TCustomWinSocket);
begin
memo1.lines.add('ok!!!')
end;
procedure TForm1.ClientSocket1Error(Sender: TObject;
Socket: TCustomWinSocket; ErrorEvent: TErrorEvent;
var ErrorCode: Integer);
begin
memo1.lines.add('error!!!')
end;
procedure TForm1.ClientSocket1Lookup(Sender: TObject;
Socket: TCustomWinSocket);
begin
memo1.lines.add('look up');
end;
end.