ADD: Capability to set 7z.dll path via .ini file

This commit is contained in:
Alexander Koblov 2015-04-11 19:39:41 +00:00
commit ef008d7329
2 changed files with 16 additions and 5 deletions

View file

@ -412,10 +412,18 @@ var
begin
// Save configuration file name
ConfigFile:= ExtractFilePath(dps^.DefaultIniName) + 'sevenzip.ini';
// Load library from plugin path
if GetModulePath(ModulePath) and FileExists(ModulePath + SevenzipDefaultLibraryName) then
// Load plugin configuration
LoadConfiguration;
// Try to find library path
if FileExists(LibraryPath) then
SevenzipLibraryName:= LibraryPath
else if GetModulePath(ModulePath) then
begin
SevenzipLibraryName:= ModulePath + SevenzipDefaultLibraryName;
if FileExists(ModulePath + TargetCPU + PathDelim + SevenzipDefaultLibraryName) then
SevenzipLibraryName:= ModulePath + TargetCPU + PathDelim + SevenzipDefaultLibraryName
else if FileExists(ModulePath + SevenzipDefaultLibraryName) then begin
SevenzipLibraryName:= ModulePath + SevenzipDefaultLibraryName;
end;
end;
// Process Xz files as archives
GetArchiveFormats.RegisterFormat(TJclXzDecompressArchive);
@ -429,8 +437,6 @@ begin
begin
MessageBoxW(0, PWideChar(UTF8Decode(rsSevenZipLoadError)), 'SevenZip', MB_OK or MB_ICONERROR);
end;
// Load plugin configuration
LoadConfiguration;
end;
procedure ConfigurePacker(Parent: WcxPlugin.HWND; DllInstance: THandle); stdcall;

View file

@ -135,6 +135,9 @@ const
cMega * 64
);
const
TargetCPU = {$I %FPCTARGETCPU%}; // Target CPU of FPC
type
TArchiveFormat = (afSevenZip, afBzip2, afGzip, afTar, afWim, afXz, afZip);
@ -167,6 +170,7 @@ procedure SaveConfiguration;
var
ConfigFile: AnsiString;
LibraryPath: AnsiString;
const
ArchiveExtension: array[TArchiveFormat] of WideString =
@ -381,6 +385,7 @@ begin
try
Ini:= TIniFile.Create(ConfigFile);
try
LibraryPath:= Ini.ReadString(TargetCPU, 'LibraryPath', EmptyStr);
for ArchiveFormat:= Low(TArchiveFormat) to High(TArchiveFormat) do
begin
Section:= GUIDToString(PluginConfig[ArchiveFormat].ArchiveCLSID^);