Xabib2302
Новичок
Доброе время суток. Помогите мне решить проблему. я использую код для изменения путь в зависимости от компонента. Проблема в том, что для распаковки портативной версии на другой путь т.е.
До выбора пути было так C:\BlueScreenView Portable
После выбора пути стало так C:\Downloads\BlueScreenView
т.е. исчезло слово Portable
Как это исправить?
Пример скрипта
До выбора пути было так C:\BlueScreenView Portable
После выбора пути стало так C:\Downloads\BlueScreenView
т.е. исчезло слово Portable
Как это исправить?
Пример скрипта
Код:
; Скрипт создан через Мастер Inno Setup Script.
; ИСПОЛЬЗУЙТЕ ДОКУМЕНТАЦИЮ ДЛЯ ПОДРОБНОСТЕЙ ИСПОЛЬЗОВАНИЯ INNO SETUP!
#define MyAppName "BlueScreenView"
#define MyAppVersion "1.52"
#define MyAppURL "https://href.li/?http://www.nirsoft.net/utils/blue_screen_view.html"
#define MyAppExeName "BlueScreenView.exe"
#include "WinTB.iss"
#include "botva2.iss"
[Setup]
; Примечание: Значение AppId идентифицирует это приложение.
; Не используйте одно и тоже значение в разных установках.
; (Для генерации значения GUID, нажмите Инструменты | Генерация GUID.)
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}
AllowNoIcons=true
OutputBaseFilename={#MyAppName} {#MyAppVersion} RePack (& Portable) by Xabib
SetupIconFile=ico.ico
Compression=lzma/Ultra64
SolidCompression=true
InternalCompressLevel=Ultra64
DiskSpanning=false
DiskSliceSize=736000000
ShowLanguageDialog=yes
SlicesPerDisk=4
UninstallDisplayIcon={app}\ico.ico
RawDataResource=Botva:botva2.dll|b2p:b2p.dll|Logo:logo.png|bPic:bPic.png|LiPic:LiPic.png|aPic:aPic.png
AppModifyPath={app}
VersionInfoProductName={#MyAppName}
DirExistsWarning=no
DisableReadyPage=true
AppID={#MyAppName}
VersionInfoDescription={#MyAppName} RePack by Xabib
AppCopyright=Xabib © 2014
VersionInfoVersion={#MyAppVersion}
VersionInfoProductVersion={#MyAppVersion}
VersionInfoCopyright=Xabib © 2014
DisableFinishedPage=false
UninstallDisplayName={#MyAppName}
ComponentsListTVStyle=true
ShowComponentSizes=false
Uninstallable=not IsComponentSelected('BSOD\P')
DisableProgramGroupPage=yes
CreateUninstallRegKey=not IsComponentSelected('BSOD\P')
InfoBeforeFile=Info.rtf
[Languages]
Name: "Russian"; MessagesFile: "Russian.isl"
[Types]
Name: full; Description: Полная установка; Flags: iscustom
[Tasks]
Name: ic; Description: 1; Components: BSOD\I;
Name: ic\desktop; Description: 2; Components: BSOD\I;
Name: ic\group; Description: 3; Components: BSOD\I;
Name: ic\quicklaunch; Description: 4; OnlyBelowVersion: 0,6.1; Components: BSOD\I; Flags: unchecked
Name: ic\taskbar; Description: 5; MinVersion: 0.0,6.1.7600; Components: BSOD\I; Flags: unchecked
Name: ic\startmenu; Description: 5; MinVersion: 0.0,6.1.7600; Components: BSOD\I; Flags: unchecked
[Components]
Name: BSOD; Description: {#MyAppName}; Flags: fixed disablenouninstallwarning; Types: full;
Name: BSOD\I; Description: Установить {#MyAppName}; Flags: exclusive disablenouninstallwarning
Name: BSOD\P; Description: Распаковать {#MyAppName}; Flags: exclusive disablenouninstallwarning
Name: L; Description: 55; Flags: fixed disablenouninstallwarning; Types: full;
Name: L\R; Description: Русский; Flags: exclusive disablenouninstallwarning;
Name: L\E; Description: Английский; Flags: exclusive disablenouninstallwarning;
Name: L\U; Description: Украинский; Flags: exclusive disablenouninstallwarning;
[Files]
;Файлы распаковываемые в папку с игрой. Необходимы для деинсталлятора;
Source: WinTB.dll; Flags: dontcopy;
Source: ico.ico; DestDir: {app}; Flags: ignoreversion
Source: ru.ini; DestDir: {app}; Flags: ignoreversion; Components: L\R; DestName: BlueScreenView_lng.ini;
Source: ua.ini; DestDir: {app}; Flags: ignoreversion; Components: L\U; DestName: BlueScreenView_lng.ini;
; Примечание: Не используйте "Flags: ignoreversion" для системных файлов
Source: {app}\*; DestDir: {app}; Flags: ignoreversion recursesubdirs createallsubdirs;
[Icons]
Name: {group}\{#MyAppName}; Filename: {app}\{#MyAppExeName}; Components: BSOD\I; Tasks: ic\group; IconFilename: {app}\ico.ico;
Name: {group}\{cm:UninstallProgram,{#MyAppName}}; Filename: {uninstallexe}; Components: BSOD\I; Tasks: ic\group; IconFilename: {app}\ico.ico;
Name: {group}\{cm:ProgramOnTheWeb,{#MyAppName}}; Filename: {#MyAppURL}; Components: BSOD\I; Tasks: ic\group;
Name: {commondesktop}\{#MyAppName}; Filename: {app}\{#MyAppExeName}; Components: BSOD\I; Tasks: ic\desktop; IconFilename: {app}\ico.ico;
Name: {userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}; Filename: {app}\{#MyAppExeName}; Components: BSOD\I; Tasks: ic\quicklaunch; IconFilename: {app}\ico.ico;
[Run]
Filename: {app}\{#MyAppExeName}; Description: "{cm:LaunchProgram,{#MyAppName}}"; Flags: nowait skipifsilent PostInstall Unchecked;
[Code]
#ifdef UNICODE
#define A "W"
#else
#define A "A"
#endif
#define A = (Defined UNICODE) ? "W" : "A"
const
///////////////////////////////////Относится к лого и изображениям мастера
RT_RCDATA = 10;
LOAD_LIBRARY_AS_DATAFILE = $2;
var
///////////////////////////////////Лого и изображения
lPLogo, bPicHandle, bPicHandle2, lPicHandle: THandle;
BtnImage: TBitmapImage;
///////////////////////////////////////////
iInitialize: Boolean;
///////////////////////////////////Ресурсы(относится к лого и изображениям мастера)
function GetFromRes(const ResName, SaveFileName: String): Boolean;
var
lResStream: TResourceStream;
begin
lResStream := TResourceStream.Create(HInstance, ResName, RT_RCDATA);
try
lResStream.SaveToFile(AddBackslash(ExpandConstant('{tmp}')) + SaveFileName);
finally
lResStream.Free;
Result := FileExists(AddBackslash(ExpandConstant('{tmp}')) + SaveFileName);
end;
end;
function OnShouldSkipPage(Sender: TWizardPage): Boolean;
begin
if WizardForm.ComponentsList.Items.Count > 0 then WizardForm.Tag:= 1; // отображаются страницы выбора папки и компонентов
end;
procedure InitializeWizard;
begin
PageFromID(wpSelectDir).OnShouldSkipPage:= @OnShouldSkipPage
with WizardForm do
begin
///////////////////////////////////Логотип и изображения мастера
iInitialize := True;
if GetFromRes('_IS_BOTVA', 'botva2.dll') and GetFromRes('_IS_B2P', 'b2p.dll') and GetFromRes('_IS_LOGO', 'logo.png') and GetFromRes('_IS_BPIC', 'bPic.png') and GetFromRes('_IS_LIPIC', 'LiPic.png') and GetFromRes('_IS_APIC', 'aPic.png') then
begin
///////////////////////////////////Изображения
bPicHandle := ImgLoad(WelcomePage.Handle, ExpandConstant('{tmp}\aPic.png'), WizardBitmapImage.Left, WizardBitmapImage.Top, WizardBitmapImage.Width, WizardBitmapImage.Height, True, True);
WizardBitmapImage.Hide;
ImgSetVisibility(bPicHandle, True);
ImgApplyChanges(WelcomePage.Handle);
bPicHandle := ImgLoad(FinishedPage.Handle, ExpandConstant('{tmp}\bPic.png'), WizardBitmapImage2.Left, WizardBitmapImage2.Top, WizardBitmapImage2.Width, WizardBitmapImage2.Height, True, True);
WizardBitmapImage2.Hide;
ImgSetVisibility(bPicHandle, True);
ImgApplyChanges(FinishedPage.Handle);
lPicHandle := ImgLoad(MainPanel.Handle, ExpandConstant('{tmp}\LiPic.png'), WizardSmallBitmapImage.Left, WizardSmallBitmapImage.Top, WizardSmallBitmapImage.Width, WizardSmallBitmapImage.Height, True, True);
WizardSmallBitmapImage.Hide;
DiskSpaceLabel.Hide;
ComponentsDiskSpaceLabel.Hide;
ImgSetVisibility(lPicHandle, True);
ImgApplyChanges(MainPanel.Handle);
////////////////////////////////////////////
///////////////////////////////////Логотип
lPLogo:= ImgLoad(WizardForm.Handle, ExpandConstant('{tmp}\logo.png'), ScaleX(20), ScaleY(318), ScaleX(124), ScaleY(40), True, True);
ImgApplyChanges(WizardForm.Handle);
end;
///////////////////////////////////WinTB
ExtractTemporaryFile('WinTB.dll');
TaskBarV10(MainForm.Handle, WizardForm.Handle, false, false, 0, 0, _m_);
//////////////////////////////////////
with TLabel.Create(WizardForm) do
begin
Parent:=WizardForm;
AutoSize:=False;
Transparent:= true;
SetBounds(ScaleX(20), ScaleY(318), ScaleX(124), ScaleY(40));
end;
end;
end;
function LoadLibraryEx(lpFileName: String; hFile: THandle; dwFlags: DWORD): THandle; external 'LoadLibraryEx{#A}@kernel32.dll stdcall';
function LoadString(hInstance: THandle; uID: SmallInt; var lpBuffer: Char; nBufferMax: Integer): Integer; external 'LoadString{#A}@user32.dll stdcall';
function SHGetNewLinkInfo(pszLinkTo, pszDir: String; var pszName: Char; var pfMustCopy: Longint; uFlags: UINT): BOOL; external 'SHGetNewLinkInfo{#A}@shell32.dll stdcall';
function PinToTaskbar(const szFilename: String; IsPin: Boolean): Boolean;
// szFilename : full path to executable file
// IsPin......: False - unpin from TaskBar, True - pin to TaskBar
var
hInst: THandle;
buf: array [0..255] of Char;
i, res: Integer;
strLnk, strVerb: String;
objShell, colVerbs: Variant;
begin
Result := False;
if (GetWindowsVersion < $06010000) or not FileExists(szFilename) then Exit; { below Windows 7 }
{ String resources }
if IsPin then
begin
if SHGetNewLinkInfo(szFilename, ExpandConstant('{tmp}'), buf[0], res, 0) then
begin
while buf[Length(strLnk)] <> #0 do Insert(buf[Length(strLnk)], strLnk, Length(strLnk)+1);
if FileExists(ExpandConstant('{userappdata}\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\') + ExtractFileName(strLnk)) then Exit;
end;
res := 5386; { Pin to Tas&kbar }
end else res := 5387; { Unpin from Tas&kbar }
{ Load string resource }
hInst := LoadLibraryEx(ExpandConstant('{sys}\shell32.dll'), 0, LOAD_LIBRARY_AS_DATAFILE);
if hInst <> 0 then
try
for i := 0 to LoadString(hInst, res, buf[0], 255)-1 do Insert(buf[i], strVerb, i+1);
try
objShell := CreateOleObject('Shell.Application');
colVerbs := objShell.Namespace(ExtractFileDir(szFilename)).ParseName(ExtractFileName(szFilename)).Verbs;
for i := 1 to colVerbs.Count do if CompareText(colVerbs.Item[i].Name, strVerb) = 0 then
begin
colVerbs.Item[i].DoIt;
Result := True;
Break;
end;
except
Exit;
end;
finally
FreeDLL(hInst);
end;
end;
/////////////////////////////////////////////////////////////////////////
function PinToStartMenu(const szFilename: String; IsPin: Boolean): Boolean;
// szFilename : full path to exe- or lnk-file
// IsPin......: False - unpin from StartMenu, True - pin to StartMenu
var
hInst: THandle;
buf: array [0..259] of Char;
i, res: Integer;
strLnk, strVerb: String;
objShell, colVerbs: Variant;
begin
Result := False;
if not FileExists(szFilename) then Exit;
if GetWindowsVersion > $06020000 then Exit; { Window 8 and above }
{ Windows 7 }
if (GetWindowsVersion >= $06010000) and boolean(SHGetNewLinkInfo(szFilename, ExpandConstant('{tmp}'), buf[0], res, 0)) then
begin
while buf[Length(strLnk)] <> #0 do Insert(buf[Length(strLnk)], strLnk, Length(strLnk)+1);
if FileExists(ExpandConstant('{userappdata}\Microsoft\Internet Explorer\Quick Launch\User Pinned\StartMenu\') + ExtractFileName(strLnk)) then Exit;
end;
{ String resources }
if IsPin then
res := 5381 { Pin to Start Men&u }
else
res := 5382; { Unpin from Start Men&u }
{ Load string resource }
hInst := LoadLibraryEx(ExpandConstant('{sys}\shell32.dll'), 0, LOAD_LIBRARY_AS_DATAFILE);
if hInst <> 0 then
try
for i := 0 to LoadString(hInst, res, buf[0], 255)-1 do Insert(buf[i], strVerb, i+1);
try
objShell := CreateOleObject('Shell.Application');
{ below Windows 7 }
if GetWindowsVersion < $06010000 then
begin
objShell.Namespace(ExtractFileDir(szFilename)).ParseName(ExtractFileName(szFilename)).InvokeVerb(strVerb);
Result := True;
end;
{ Windows 7 }
if GetWindowsVersion >= $06010000 then
begin
colVerbs := objShell.Namespace(ExtractFileDir(szFilename)).ParseName(ExtractFileName(szFilename)).Verbs;
for i := 1 to colVerbs.Count do if CompareText(colVerbs.Item[i].Name, strVerb) = 0 then
begin
colVerbs.Item[i].DoIt;
Result := True;
Break;
end;
end;
except
Exit;
end;
finally
FreeDLL(hInst);
end;
end;
function ParamExists(S: String): Boolean;
var
i: Integer;
begin
Result:= False;
for i:= 0 to ParamCount() do begin
if Pos(Uppercase(S), Uppercase(ParamStr(i))) > 0 then begin
Result:= true;
Break;
end;
end;
end;
function GetCmdDirValue(): String;
var
i: Integer;
begin
Result:= '';
for i:= 0 to ParamCount() do begin
if (Pos('/DIR', Uppercase(ParamStr(i))) > 0) then begin
Result:= Copy(ParamStr(i), 6, Length(ParamStr(i)));
StringChange(Result, 'expand:', '');
StringChange(Result, 'EXPAND:', '');
Result:= ExpandConstant(Result);
Break;;
end;
end;
end;
Procedure CurPageChanged(CurPageID: Integer);
Begin
Case CurPageID of
wpFinished:
begin
if IsTaskSelected('ic\taskbar') then
PinToTaskbar(ExpandConstant('{app}\{#MyAppExeName}'), True);
if IsTaskSelected('ic\startmenu') then
PinToStartMenu(ExpandConstant('{app}\{#MyAppExeName}'), True);
end;
wpSelectTasks:
if IsComponentSelected('BSOD\I') then
begin
WizardForm.NextButton.Caption:= SetupMessage(msgButtonInstall);
end;
wpSelectDir: if WizardForm.Tag = 1 then
begin
WizardForm.SelectDirPage.Notebook.ActivePage:= WizardForm.SelectComponentsPage;
WizardForm.PageNameLabel.Caption:= SetupMessage(msgWizardSelectComponents);
WizardForm.Hint:= WizardForm.PageDescriptionLabel.Caption; // запомнить SetupMessage(msgSelectDirDesc)
WizardForm.PageDescriptionLabel.Caption:= SetupMessage(msgSelectComponentsDesc);
end;
wpSelectComponents: if WizardForm.Tag = 1 then
begin
WizardForm.SelectComponentsPage.Notebook.ActivePage:= WizardForm.SelectDirPage;
WizardForm.DiskSpaceLabel.Caption:= WizardForm.ComponentsDiskSpaceLabel.Caption;
WizardForm.PageNameLabel.Caption:= SetupMessage(msgWizardSelectDir);
WizardForm.PageDescriptionLabel.Caption:= WizardForm.Hint; // иначе вместо названия программы [name]
if (not ParamExists('/dir')) then begin
if IsComponentSelected('BSOD\I') then
WizardForm.DirEdit.Text :=(ExpandConstant('{#SetupSetting("DefaultDirName")}'))
else if IsComponentSelected('BSOD\P') then begin
WizardForm.DirEdit.Text := AddBackslash(ExpandConstant('{src}')) + '{#MyAppName} Portable'
WizardForm.NextButton.Caption:= SetupMessage(msgButtonInstall);
end;
end else
WizardForm.DirEdit.Text := GetCmdDirValue();
end;
end;
end;
procedure DeinitializeSetup();
begin
if iInitialize then
begin
gdipShutdown;
TaskBarDestroy;
end;
end;
procedure InitializeUninstallProgressForm;
begin
with UninstallProgressForm do
begin
///////////////////////////////////Логотип и изображения мастера
if GetFromRes('_IS_BOTVA', 'botva2.dll') and GetFromRes('_IS_B2P', 'b2p.dll') and GetFromRes('_IS_LOGO', 'logo.png') and GetFromRes('_IS_LIPIC', 'LIPic.png') then
begin
///////////////////////////////////Изображения
lPicHandle := ImgLoad(MainPanel.Handle, ExpandConstant('{tmp}\LiPic.png'), WizardSmallBitmapImage.Left, WizardSmallBitmapImage.Top, WizardSmallBitmapImage.Width, WizardSmallBitmapImage.Height, True, True);
WizardSmallBitmapImage.Hide;
ImgSetVisibility(lPicHandle, True);
ImgApplyChanges(MainPanel.Handle);
///////////////////////////////////Логотип
lPLogo:= ImgLoad(UninstallProgressForm.Handle, ExpandConstant('{tmp}\logo.png'), ScaleX(20), ScaleY(318), ScaleX(124), ScaleY(40), True, True);
ImgApplyChanges(UninstallProgressForm.Handle);
end;
with TLabel.Create(nil) do
begin
Parent:=UninstallProgressForm;
AutoSize:=False;
Transparent:= true;
SetBounds(ScaleX(20), ScaleY(318), ScaleX(124), ScaleY(40));
end;
end;
end;
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
var
instPath: string;
begin
case CurUninstallStep of
usUninstall:
begin
PinToTaskbar(ExpandConstant('{app}\{#MyAppExeName}'), False);
PinToStartMenu(ExpandConstant('{app}\{#MyAppExeName}'), False);
end;
end;
end;
procedure DeinitializeUninstall();
begin
if iInitialize then gdipShutdown;
end;
[UninstallDelete]
Name: {app}; Type: filesandordirs;
Последнее редактирование: