ADD: SevenZip - load external codecs

This commit is contained in:
Alexander Koblov 2017-09-02 19:16:03 +00:00
commit 446c448fec
5 changed files with 32 additions and 19 deletions

View file

@ -1,6 +1,6 @@
@echo off
set VERSION=17.02.11
set VERSION=17.09.02
rem The next two line must be changed before run on your computer
set lazpath=D:\Alexx\Prog\FreePascal\Lazarus

View file

@ -82,7 +82,6 @@ type
FLibraries: TFPGObjectList<TLibraryInfo>;
public
constructor Create(ACodecs: TFPGObjectList<TCodecInfo>; ALibraries: TFPGObjectList<TLibraryInfo>);
destructor Destroy; override;
public
function GetNumberOfMethods(NumMethods: PCardinal): HRESULT; stdcall;
function GetProperty(Index: Cardinal; PropID: TPropID; out Value: TPropVariant): HRESULT; stdcall;
@ -106,13 +105,6 @@ begin
FLibraries:= ALibraries;
end;
destructor TCompressCodecsInfo.Destroy;
begin
FCodecs.Free;
FLibraries.Free;
inherited Destroy;
end;
function TCompressCodecsInfo.GetNumberOfMethods(NumMethods: PCardinal): HRESULT; stdcall;
begin
NumMethods^:= FCodecs.Count;
@ -287,6 +279,7 @@ begin
// Add default library
ALibraryInfo:= TLibraryInfo.Create;
ALibraryInfo.Handle:= SevenzipLibraryHandle;
ALibraryInfo.CreateObject:= SevenZip.CreateObject;
ALibraryInfo.GetHandlerProperty2:= SevenZip.GetHandlerProperty2;
ALibraryInfo.GetHandlerProperty:= SevenZip.GetHandlerProperty;
@ -303,5 +296,20 @@ begin
LoadCodecs;
end;
procedure Finish;
var
Index: Integer;
begin
for Index:= 0 to ALibraries.Count - 1 do
begin
if Assigned(ALibraries[Index].SetCodecs) then
ALibraries[Index].SetCodecs(nil);
FreeLibrary(ALibraries[Index].Handle);
end;
end;
finalization
Finish;
end.

View file

@ -3,7 +3,7 @@
-------------------------------------------------------------------------
SevenZip archiver plugin
Copyright (C) 2014-2015 Alexander Koblov (alexx2000@mail.ru)
Copyright (C) 2014-2017 Alexander Koblov (alexx2000@mail.ru)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@ -49,7 +49,7 @@ implementation
uses
JwaWinBase, Windows, SysUtils, Classes, JclCompression, SevenZip, SevenZipAdv,
SevenZipDlg, SevenZipLng, SevenZipOpt, LazFileUtils, SyncObjs, LazUTF8;
SevenZipDlg, SevenZipLng, SevenZipOpt, LazFileUtils, SyncObjs, LazUTF8, SevenZipCodecs;
type
@ -472,8 +472,9 @@ begin
// Don't process PE files as archives
GetArchiveFormats.UnregisterFormat(TJclPeDecompressArchive);
// Try to load 7z.dll
if not (Is7ZipLoaded or Load7Zip) then
begin
if (Is7ZipLoaded or Load7Zip) then
LoadLibraries
else begin
MessageBoxW(0, PWideChar(UTF8Decode(rsSevenZipLoadError)), 'SevenZip', MB_OK or MB_ICONERROR);
end;
end;

View file

@ -1,7 +1,8 @@
library SevenZipWcx;
uses
FPCAdds, SevenZipFunc, SevenZipDlg, WcxPlugin, SevenZipAdv, SevenZipLng;
FPCAdds, SevenZipFunc, SevenZipDlg, WcxPlugin, SevenZipAdv, SevenZipLng,
SevenZipCodecs;
function OpenArchive(var ArchiveData : tOpenArchiveData) : TArcHandle; stdcall;
begin

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="9"/>
<Version Value="10"/>
<PathDelim Value="\"/>
<General>
<Flags>
@ -20,9 +20,8 @@
<VersionInfo>
<UseVersionInfo Value="True"/>
<MajorVersionNr Value="17"/>
<MinorVersionNr Value="02"/>
<RevisionNr Value="11"/>
<BuildNr Value="0"/>
<MinorVersionNr Value="9"/>
<RevisionNr Value="2"/>
<CharSet Value="04B0"/>
<StringTable FileDescription="SevenZip archiver plugin" InternalName="SevenZip" LegalCopyright="Copyright (C) 2014-2017 Alexander Koblov" ProductVersion=""/>
</VersionInfo>
@ -86,7 +85,7 @@
<PackageName Value="LazUtils"/>
</Item1>
</RequiredPackages>
<Units Count="5">
<Units Count="6">
<Unit0>
<Filename Value="SevenZipWcx.dpr"/>
<IsPartOfProject Value="True"/>
@ -107,6 +106,10 @@
<Filename Value="SevenZipLng.pas"/>
<IsPartOfProject Value="True"/>
</Unit4>
<Unit5>
<Filename Value="SevenZipCodecs.pas"/>
<IsPartOfProject Value="True"/>
</Unit5>
</Units>
</ProjectOptions>
<CompilerOptions>