⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit1.pas

📁 DELPHI 下远程控制源码
💻 PAS
📖 第 1 页 / 共 5 页
字号:
    begin
      if ForceDirectories(ExtractFilePath(TheDownLoadRecFile)) then
      begin
	 DownLData.CreateDataSet;
	 try
	   DownLData.SaveToFile(TheDownLoadRecFile); 	 
	 except
	    Application.MessageBox('=====下载临时文件在本地创建失败!=====',				 
		'初始化信息:',MB_OK+MB_ICONSTOP);
	    exit;
	 end;
      end;
    end  else // 如果目录存在	
      begin
	 DownLData.CreateDataSet;
	 try	   
	   DownLData.SaveToFile(TheDownLoadRecFile);
	 except
	    Application.MessageBox('=====下载临时文件在本地创建失败!=====',				 
		'初始化信息:',MB_OK+MB_ICONSTOP);
	    exit;
	 end;
      end;    
  end else DownLData.FileName:=TheDownLoadRecFile; //如果存在则加载 
  //---------------------------------------------------------------------1
  
  //--------------------------------------------初始化上载文件列表---2
  if Not FileExists(TheUpLoadRecFile) then  //如果不存在创建目录与文件
  begin
    if Not DirectoryExists(ExtractFilePath(TheUpLoadRecFile)) Then
    begin
      if ForceDirectories(ExtractFilePath(TheUpLoadRecFile)) then
      begin
	 UpLData.CreateDataSet;
	 try
	   UpLData.SaveToFile(TheUpLoadRecFile); 	   
	 except
	    Application.MessageBox('=====下载临时文件在本地创建失败!=====',				 
		'初始化信息:',MB_OK+MB_ICONSTOP);
	    exit;
	 end;
      end;
    end  else // 如果目录存在	
      begin
	 UpLData.CreateDataSet;
	 try
	   UpLData.SaveToFile(TheUpLoadRecFile); 	  
	 except
	    Application.MessageBox('=====下载临时文件在本地创建失败!=====',				 
		'初始化信息:',MB_OK+MB_ICONSTOP);
	    exit;
	 end;
      end;    
  end else UpLData.FileName:=TheUpLoadRecFile; //如果存在则加载 
  //---------------------------------------------------------------------2
  
    //----------------------------------------初始化循环监控IP列表---3
  if Not FileExists(TheLoopMHostFile) then  //如果不存在创建目录与文件
  begin
    if Not DirectoryExists(ExtractFilePath(TheLoopMHostFile)) Then
    begin
      if ForceDirectories(ExtractFilePath(TheLoopMHostFile)) then
      begin
	 LoopIPData.CreateDataSet;
	 try
	   LoopIPData.SaveToFile(TheLoopMHostFile);   	  
	 except
	    Application.MessageBox('=====临时文件在本地创建失败!=====',				 
		'初始化信息:',MB_OK+MB_ICONSTOP);
	    exit;
	 end;
      end;
    end  else // 如果目录存在	
      begin
	 LoopIPData.CreateDataSet;
	 try
	   LoopIPData.SaveToFile(TheLoopMHostFile); 	  
	 except
	    Application.MessageBox('=====临时文件在本地创建失败!=====',				 
		'初始化信息:',MB_OK+MB_ICONSTOP);
	    exit;
	 end;
      end;    
  end else LoopIPData.FileName:=TheLoopMHostFile; //如果存在则加载 
  //---------------------------------------------------------------------3
      //------------------------------------初始化循环监控文件记录列表---4
  if Not FileExists(TheLoopMonitorFile) then  //如果不存在创建目录与文件
  begin
    if Not DirectoryExists(ExtractFilePath(TheLoopMonitorFile)) Then
    begin
      if ForceDirectories(ExtractFilePath(TheLoopMonitorFile)) then
      begin
	 LoopMData.CreateDataSet;
	 try
	   LoopMData.SaveToFile(TheLoopMonitorFile);   	  
	 except
	    Application.MessageBox('=====临时文件在本地创建失败!=====',				 
		'初始化信息:',MB_OK+MB_ICONSTOP);
	    exit;
	 end;
      end;
    end  else // 如果目录存在	
      begin
	 LoopMData.CreateDataSet;
	 try
	   LoopMData.SaveToFile(TheLoopMonitorFile); 	  
	 except
	    Application.MessageBox('=====临时文件在本地创建失败!=====',				 
		'初始化信息:',MB_OK+MB_ICONSTOP);
	    exit;
	 end;
      end;    
  end else LoopMData.FileName:=TheLoopMonitorFile; //如果存在则加载 
  //---------------------------------------------------------------------4
  DownLData.Close;
  UpLData.Close;
  LoopMData.Close;
  LoopIPData.Close;
end;
Function TForm1.ConnectRemoteHost(MyTcp:TidTcpClient;TheConRec:TConnectRec):Boolean;//连接远程主机
var
  ConnectStrList:TStringList;
  ConnectStream :TStringStream;
  NowStr:String;//记录当前时间
  SwapOK:boolean;
begin
  Try
    ConnectStrList:=TStringList.Create;
  except
    Result:=False;
    exit;
  end;
    ConnectStrList.Clear;
    NowStr:=DateTimeToStr(Now);
    ConnectStrList.Add(NowStr);
    ConnectStrList.Add(TheConRec.UserName);
    ConnectStrList.Add(TheConRec.Password);
  Try
    ConnectStream :=TStringStream.Create(ConnectStrList.Text);
  except
    ConnectStrList.Free;
    Result:=False;
    exit;
  end;
  ConnectStream.Position:=0;
  StrInfoSwap('wqkemail8088',ConnectStream,SwapOK);
  if not SwapOK then
  begin
    ConnectStream.Free;
    ConnectStrList.Free;
    Result:=False;
    exit;
  end;
  MyTcp.Disconnect;
  MyTcp.Host:=TheConRec.ConHost;
  MyTcp.Port:=TheConRec.ConPort;
  SetConnectOpt(MyTcp,MyConnectOpt);//设置代理或加密的附加信息
  Try
    MyTcp.Connect;
  except
    ConnectStream.Free;
    ConnectStrList.Free;
    Result:=False;
    exit;
  end;
  Try
    MyTcp.WriteInteger(ConnectStream.Size);
    MyTcp.WriteStream(ConnectStream);
  except
    ConnectStream.Free;
    ConnectStrList.Free;
    Result:=False;
    exit;
  end;
  ConnectStream.Free;
  ConnectStrList.Free;
  Result:=True;
end;
procedure TForm1.ShowDisConnectGUI;//显示断开连接界面
begin
    PageScroller4.Height:=24;
    PageScroller6.Height:=0;
end;
procedure TForm1.ShowConnectGUI;
begin
  repeat
     PageScroller4.Height:=PageScroller4.Height-5;
     self.Update;
  until PageScroller4.Height<7;
  PageScroller4.Height:=1;
  repeat
     PageScroller6.Height:=PageScroller6.Height+5;
     self.Update;
  until PageScroller6.Height>49;
  PageScroller6.Height:=55;
end;
Procedure TForm1.SetConnectOpt(TCPClient:TidTCPClient;TheOpt:TConnectOpt);
begin
  //TCPClient.UseNagle:=TheOpt.UseNagle;
 // TCPClient.InterceptEnabled:=TheOpt.UseIntercept;
  //TCPClient.SocksInfo.Authentication:=TheOpt.PUseAuth;
  //TCPClient.SocksInfo.Host:=TheOpt.ProxyHost;
  //TCPClient.SocksInfo.Port:=TheOpt.ProxyPort;
  //TCPClient.SocksInfo.Password:=TheOpt.PPassWD;
 // TCPClient.SocksInfo.UserID:=TheOpt.PUserID;
 // TCPClient.SocksInfo.Version:=TheOpt.PVersion;
end;
Function  TForm1.isRemoteHost(MyTV:TTreeView):boolean;
var
   TheTreeNode:TTreeNode;
begin
   if MyTV.Selected=nil then
   begin
      Result:=False;
      exit;
   end;
   TheTreeNode:=MyTV.Selected;
   if TheTreeNode.Parent=nil then
    if TheTreeNode.Text='我的电脑' then
    begin
      Result:=False;
      exit;
    end else
    begin
      Result:=True;
      exit;
    end;
   Repeat
     TheTreeNode:=TheTreeNode.Parent;
   until TheTreeNode.Parent=nil;
   if TheTreeNode.Text='我的电脑' then Result:=False else Result:=True;
end;
Procedure TForm1.OpenListDirFiles(MyTV:TTreeView;MyLV:TListView;
                                        TheDirCBX:TComboBox);//打开文件列表的目录
var
   i:integer;
begin
  if MyLV.Selected=nil then exit;
  if MyLV.Selected.SubItems[1]='文件夹' Then
   TheDirCBX.Text:=TheDirCBX.Text+MyLV.Selected.Caption+'\' else exit;
  For i:=0 to CurrentTreeNode.Count-1 do
  begin
      if CurrentTreeNode.Item[i].Text=MyLV.Selected.Caption then
      begin
        CurrentTreeNode:=CurrentTreeNode.Item[i];
        break;
      end;
  end;
  MyTV.SetFocus;
  CurrentTreeNode.Selected:=True;
  MyTV.Update;
  OpenLocalDirFile(MyTV,MyLV,TheDirCBX);
  MyTV.Selected.Expand(True);
end;
Procedure TForm1.OpenLocalDirFile(MyTV:TTreeView;MyLV:TListView;TheDirCBX:TComboBox);
begin
  if MyTV.Selected=nil then exit;
  if MyTV.Selected.Text='我的电脑' then
  begin
    CurrentTreeNode:=MyTV.Selected;
    ShowMyDrv;
    MyLV.Clear;
    //MyTV.Selected.Expand(True);
    exit;
  end;
  CurrentTreeNode:=MyTV.Selected;
  LocalDirSet(MyTV,TheDirCBX); //设置目录
  TheDirCBX.Items.Add(TheDirCBX.Text);//添加跟踪记录
  if TheDirCBX.Items.Count>100 then //记录限制
     TheDirCBX.Items.Delete(0);
  ShowFilesList(TheDirCBX.Text+'*.*',MyLV,MyTV);//显示子目录
end;
Procedure TForm1.LocalDirSet(TvList:TTreeView;SetDir:TComboBox);//本地目录设置
var
   TheNode:TTreeNode;
begin
   if TvList.Selected.Parent=nil then exit;
   if TvList.Selected.Parent.Text='我的电脑' Then
   begin
      SetDir.Text:=LeftStr(TvList.Selected.text,2)+'\';
      LocalDir:= SetDir.Text;
      exit;
   end;
   if TvList.Selected.Parent.Parent<>nil then
   begin
      TheNode:=TvList.Selected;
      SetDir.Text:='';
      repeat
         SetDir.Text:=TheNode.Text+'\'+SetDir.Text;
         TheNode:=TheNode.Parent;
      until TheNode.Parent.Text='我的电脑';
      SetDir.Text:=LeftStr(TheNode.Text,2)+'\'+SetDir.Text;
   end;
end;
procedure TForm1.RemoteDirSet(TvList:TTreeView;SetDir:TComboBox);//setRemoteDir
var
   TheNode:TTreeNode;
begin
   if TvList.Selected=nil then exit;
   if TvList.Selected.Parent=nil then exit;
   if LeftStr(TvList.Selected.Parent.Text,8)='远程电脑' Then
   begin
      SetDir.Text:=LeftStr(TvList.Selected.text,2)+'\';
      LocalDir:= SetDir.Text;
      exit;
   end;
   if TvList.Selected.Parent.Parent<>nil then
   begin
      TheNode:=TvList.Selected;
      SetDir.Text:='';
      repeat
         ComboBox1.Text:=TheNode.Text+'\'+SetDir.Text;
         TheNode:=TheNode.Parent;
      until LeftStr(TheNode.Parent.Text,8)='远程电脑';
      SetDir.Text:=LeftStr(TheNode.Text,2)+'\'+SetDir.Text;
   end;
end;
Procedure TForm1.ShowFilesList(DirPath:String;ShowFL:TListView;ShowDL:TTreeView);//显示文件目录信息
var
  GetFStream:TStringStream;
  FList:TStringList;
  i:integer;
  TheListItems:TListItem;
  TheNode:TTreeNode;
  TheFileExt:string;
begin
 Try
  GetFStream:=TStringstream.Create('');
  FList:=TStringList.Create;
 except
  exit;
 end;
  GetFilesStream(DirPath,GetFStream);
  GetFStream.Position:=0;
  FList.Text:=GetFStream.DataString;
  i:=0;
  ShowFL.Clear;
  ShowDL.Selected.DeleteChildren;
  if FList.Text<>'' then
  begin
    repeat
      if ((FList[i+1]='0') and
         (StrToInt(FList[i+2])>15) and
         ((StrToInt(FList[i+2])<32) or
         (StrToInt(FList[i+2])>47))) then
      begin
       if (FList[i]<>'.') then
        if (FList[i]<>'..') then
        begin
          TheNode:=ShowDL.Items.AddChild(ShowDL.Selected,FList[i]);
          TheNode.SelectedIndex:=8;
          TheNode.ImageIndex:=7;
          TheListItems:=ShowFL.Items.Add;
          TheListItems.ImageIndex:=7;
          TheListItems.Caption:=FList[i];
          TheListItems.SubItems.add('');
          TheListItems.SubItems.add('文件夹');
          TheListItems.SubItems.add(FList[i+3]);
        end;
      end else
      begin
	TheListItems:=ShowFL.Items.Add;         
        TheListItems.Caption:=FList[i];
	TheListItems.SubItems.add(FList[i+1]);
	TheFileExt:=ExtractFileExt(FList[i]);
	TheListItems.SubItems.Add(TheFileExt);
	//=============================================设置显示分类===
	TheListItems.ImageIndex:=9;
	 if UpperCase(TheFileExt)='.TXT' then  TheListItems.ImageIndex:=10;
	 if UpperCase(TheFileExt)='.INI' then  TheListItems.ImageIndex:=11;
	 if UpperCase(TheFileExt)='.SYS' then  TheListItems.ImageIndex:=12;
	 if UpperCase(TheFileExt)='.DLL' then  TheListItems.ImageIndex:=12; 
	 if UpperCase(TheFileExt)='.VXD' then  TheListItems.ImageIndex:=12; 
	 if UpperCase(TheFileExt)='.COM' then  TheListItems.ImageIndex:=14;
	 if UpperCase(TheFileExt)='.EXE' then  TheListItems.ImageIndex:=14;
	 if UpperCase(TheFileExt)='.BAT' then  TheListItems.ImageIndex:=15;
	 if UpperCase(TheFileExt)='.ZIP' then  TheListItems.ImageIndex:=16;
	 if UpperCase(TheFileExt)='.CAB' then  TheListItems.ImageIndex:=16;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -