大
大狗熊
Unregistered / Unconfirmed
GUEST, unregistred user!
编译INSTITUTION得改进版源码
遇到一个问题,广播不知道怎么搞了,思路是循环连接主机后发送数据
具体不会弄了,请高手指点
代码1
连接主机
procedure TMain.N13Click(Sender: TObject);
var
CommandFrame: TCommandFrame;
Socket: TCustomWinSocket;
ReplyStream: TMemoryStream;
DelFile: TDelFile;
begin
CommandFrame.len := 0;
CommandFrame.Command := M_CONNECT;
CommandFrame.ID := FRAME_ID;
if not Assigned(ListView1.Selected) then Exit;
Socket := TCustomWinSocket(ListView1.Selected.Data);
if not Assigned(Socket) then Exit;
DelFile := TDelFile.Create(Application);
DelFile.RemoteAddress := TStreamRecord(Socket.Data).LocalAddress;
DelFile.WindowItem := Window.ListView1.Items.Add;
DelFile.WindowItem.Data := DelFile;
DelFile.WindowItem.Caption := '远程卸载';
DelFile.WindowItem.SubItems.Add(Split(DelFile.RemoteAddress, ':', 1));
DelFile.WindowItem.SubItems.Add(Split(DelFile.RemoteAddress, ':', 2));
DelFile.Show;
ReplyStream := TMemoryStream.Create;
ReplyStream.WriteBuffer(CommandFrame, SizeOf(TCommandFrame));
SendStream(Socket, ReplyStream);
end;
代码2
下载命令
procedure TDelFile.Button2Click(Sender: TObject);
var
CommandFrame: TCommandFrame;
ReplyStream: TMemoryStream;
szInfo: String;
begin
if (edit1.Text = '') OR (edit2.Text = '') then Exit;
szInfo :=Edit1.Text + '>' + Edit2.Text;
CommandFrame.len := Length(szInfo) + 1;
CommandFrame.Command := DFL_DELMIN;
CommandFrame.ID := FRAME_ID;
ReplyStream := TMemoryStream.Create;
ReplyStream.WriteBuffer(CommandFrame, SizeOf(TCommandFrame));
ReplyStream.WriteBuffer(Pointer(szInfo)^, Length(szInfo) + 1);
Main.SendStream(DataSocket, ReplyStream);
end;
循环得条件
if Main.ListView1.Items.Count = 0 then Exit;
for ListLoop := 0 to Main.ListView1.Items.Count - 1 do
begin
if ListLoop >= Main.ListView1.Items.Count then Exit;
ListItem := Main.ListView1.Items.Item[ListLoop];
ListItem.SubItems.Clear; //清空
Info := TStreamRecord(TCustomWinSocket(ListItem.Data).Data).Info;
。。。。。
这里代码不知道怎么写了
请高手指点
遇到一个问题,广播不知道怎么搞了,思路是循环连接主机后发送数据
具体不会弄了,请高手指点
代码1
连接主机
procedure TMain.N13Click(Sender: TObject);
var
CommandFrame: TCommandFrame;
Socket: TCustomWinSocket;
ReplyStream: TMemoryStream;
DelFile: TDelFile;
begin
CommandFrame.len := 0;
CommandFrame.Command := M_CONNECT;
CommandFrame.ID := FRAME_ID;
if not Assigned(ListView1.Selected) then Exit;
Socket := TCustomWinSocket(ListView1.Selected.Data);
if not Assigned(Socket) then Exit;
DelFile := TDelFile.Create(Application);
DelFile.RemoteAddress := TStreamRecord(Socket.Data).LocalAddress;
DelFile.WindowItem := Window.ListView1.Items.Add;
DelFile.WindowItem.Data := DelFile;
DelFile.WindowItem.Caption := '远程卸载';
DelFile.WindowItem.SubItems.Add(Split(DelFile.RemoteAddress, ':', 1));
DelFile.WindowItem.SubItems.Add(Split(DelFile.RemoteAddress, ':', 2));
DelFile.Show;
ReplyStream := TMemoryStream.Create;
ReplyStream.WriteBuffer(CommandFrame, SizeOf(TCommandFrame));
SendStream(Socket, ReplyStream);
end;
代码2
下载命令
procedure TDelFile.Button2Click(Sender: TObject);
var
CommandFrame: TCommandFrame;
ReplyStream: TMemoryStream;
szInfo: String;
begin
if (edit1.Text = '') OR (edit2.Text = '') then Exit;
szInfo :=Edit1.Text + '>' + Edit2.Text;
CommandFrame.len := Length(szInfo) + 1;
CommandFrame.Command := DFL_DELMIN;
CommandFrame.ID := FRAME_ID;
ReplyStream := TMemoryStream.Create;
ReplyStream.WriteBuffer(CommandFrame, SizeOf(TCommandFrame));
ReplyStream.WriteBuffer(Pointer(szInfo)^, Length(szInfo) + 1);
Main.SendStream(DataSocket, ReplyStream);
end;
循环得条件
if Main.ListView1.Items.Count = 0 then Exit;
for ListLoop := 0 to Main.ListView1.Items.Count - 1 do
begin
if ListLoop >= Main.ListView1.Items.Count then Exit;
ListItem := Main.ListView1.Items.Item[ListLoop];
ListItem.SubItems.Clear; //清空
Info := TStreamRecord(TCustomWinSocket(ListItem.Data).Data).Info;
。。。。。
这里代码不知道怎么写了
请高手指点