recurir a la pesada Clase TFileStream , esta es full WinAPI y muy liviana!
Autor : ØnLy
Agradecimientos : winapi.conclase.net
Lenguaje: Pascal/Delphi
Descripcion: Carga un archivo binario en un string( RunTime)
Código: Seleccionar todo
Uses
Windows;
function ArchivoToString( path: string) : string;
var
Archivo : THandle;
talla , bytesleidos : Cardinal;
buffer : String;
begin
Archivo := CreateFile(PChar(path),GENERIC_READ, FILE_SHARE_READ,nil, OPEN_EXISTING,0,0); //Abrimos e archivo para ectura
if Archivo <> INVALID_HANDLE_VALUE then begin
//Obtenemos el tamano del archhivio
talla := GetFileSize( Archivo , nil );
SetLength( buffer , talla); //Le ponemos al string la dmensn del archivo
ReadFile(Archivo , buffer[1] , talla , bytesleidos , nil ); //Leemos la data y la metemos en el string
CloseHandle( Archivo );//Cerramos el handle
Result := buffer; //rETORNMAOS EL STRIN CON LA DATA
end;
if Archivo = INVALID_HANDLE_VALUE then begin
Result := 'ERROR'; //Si no podemos abrir el archivo tretornamos error1
end;
end;
Saludos!