pistacer
asked on
compresing
how to use the functionality of windows wich enables to compress and uncompress the data? i mean the packages *.CAB, wich are used in win installations.
i need to compress any file to optimize it;s movement thru the net. there is no need to protect the data by coding them.
i need to compress any file to optimize it;s movement thru the net. there is no need to protect the data by coding them.
you can use TCabFile from TMS software or Delphi Zip components from http://www.geocities.com/SiliconValley/Network/2114/index.html
ASKER
well, i hoped for the "native way" - i mean i do not want to use any zips, rars or something else and i want not to buy something (if it is possible). i would like to build my own unit/component to provide this.
does anybody know the sources of descriptions for this problem? any literatury, when the components are not awailable.
does anybody know the sources of descriptions for this problem? any literatury, when the components are not awailable.
well you can do all the work yourself if you want to
just download the CAB SDK from here :
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncabsdk/html/cabdl.asp
I'll try to find a free delphi cab wrapper
just download the CAB SDK from here :
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncabsdk/html/cabdl.asp
I'll try to find a free delphi cab wrapper
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
dont know how 2 use *.cab but i do know how 2 compress files + add them together like winzip heres the comopression part you will need to declare zlib in the USES part!
procedure CompressStream(inpStream, outStream: TStream);
var
InpBuf,OutBuf: Pointer;
InpBytes,OutBytes: integer;
begin
InpBuf := nil;
OutBuf := nil;
try
GetMem(InpBuf,inpStream.si ze);
inpStream.Position := 0;
InpBytes := inpStream.Read(InpBuf^,inp Stream.siz e);
CompressBuf(InpBuf,InpByte s,OutBuf,O utBytes);
outStream.Write(OutBuf^,Ou tBytes);
finally
if InpBuf <> nil then FreeMem(InpBuf);
if OutBuf <> nil then FreeMem(OutBuf);
end;
end;
procedure DecompressStream(inpStream , outStream: TStream);
var
InpBuf,OutBuf: Pointer;
OutBytes,sz: integer;
begin
InpBuf := nil;
OutBuf := nil;
sz := inpStream.size-inpStream.P osition;
if sz > 0 then try
GetMem(InpBuf,sz);
inpStream.Read(InpBuf^,sz) ;
DecompressBuf(InpBuf,sz,0, OutBuf,Out Bytes);
outStream.Write(OutBuf^,Ou tBytes);
finally
if InpBuf <> nil then FreeMem(InpBuf);
if OutBuf <> nil then FreeMem(OutBuf);
end;
outStream.Position := 0;
end;
procedure CompressStream(inpStream, outStream: TStream);
var
InpBuf,OutBuf: Pointer;
InpBytes,OutBytes: integer;
begin
InpBuf := nil;
OutBuf := nil;
try
GetMem(InpBuf,inpStream.si
inpStream.Position := 0;
InpBytes := inpStream.Read(InpBuf^,inp
CompressBuf(InpBuf,InpByte
outStream.Write(OutBuf^,Ou
finally
if InpBuf <> nil then FreeMem(InpBuf);
if OutBuf <> nil then FreeMem(OutBuf);
end;
end;
procedure DecompressStream(inpStream
var
InpBuf,OutBuf: Pointer;
OutBytes,sz: integer;
begin
InpBuf := nil;
OutBuf := nil;
sz := inpStream.size-inpStream.P
if sz > 0 then try
GetMem(InpBuf,sz);
inpStream.Read(InpBuf^,sz)
DecompressBuf(InpBuf,sz,0,
outStream.Write(OutBuf^,Ou
finally
if InpBuf <> nil then FreeMem(InpBuf);
if OutBuf <> nil then FreeMem(OutBuf);
end;
outStream.Position := 0;
end;
ASKER
well, the cab sdk is the best solution of my needs, so i will accept Lee_Nover's answers.
but i thank for all yours interresting comments!
but i thank for all yours interresting comments!
ASKER
thanks Lee_Nover!