Diskuze: Instalace programu
V předchozím kvízu, Test znalostí C# .NET online, jsme si ověřili nabyté zkušenosti z kurzu.

Neregistrovaný

Zobrazeno 9 zpráv z 9.
//= Settings::TRACKING_CODE_B ?> //= Settings::TRACKING_CODE ?>
V předchozím kvízu, Test znalostí C# .NET online, jsme si ověřili nabyté zkušenosti z kurzu.
Pokud vím tak tohle by měl umět externí instalátor typu: Advance
Installer, nebo Inno setup compiler. U advance installeru vím že si to tam
můžeš naklikat u Inno setupu už si tím nejsem jistý. Každopádně zde: http://www.itnetwork.cz/…tup-compiler
máš odkaz na vytvoření jednoduchého instalátoru v Innu.
Děkuju za radu a nechci aby to znělo nevděčně, ale inno znám a to umí jen zjistit zda je v PC framework instalován a případně odkázat na soubor ke stažení. To je právě to co mi vadilo na msi. To samé mám, ale chci dosáhnout toho, že instalátor zjistí přítomnost a pokud není, tak bud stáhnout a následně instalovat v procesu instalace nebo treba by v balíčku framework byl a jen si ho v nepřítomnosti vzal a rovnou instaloval. Následně by pokračoval v instalaci souboru.
V tom případě zkus ten Advance Installer Myslím že ten to umí.
Ten jsem teď otestoval a ten to taky neumí. Inno to umí, ale dopátral jsem se tohodle kodu, který je prý funkční, ale nechápu kam mám dát tu knihovnu. Sice jsem jí sehnal, ale nevim kam jí mám umístit. Přikládám kod:
[Code]
var
dotnetRedistPath: string;
downloadNeeded: boolean;
dotNetNeeded: boolean;
memoDependenciesNeeded: string;
procedure isxdl_AddFile(URL, Filename: PChar);
external 'isxdl_AddFile@files:isxdl.dll stdcall';
function isxdl_DownloadFiles(hWnd: Integer): Integer;
external 'isxdl_DownloadFiles@files:isxdl.dll stdcall';
function isxdl_SetOption(Option, Value: PChar): Integer;
external 'isxdl_SetOption@files:isxdl.dll stdcall';
const
dotnetRedistURL =
'http://www.microsoft.com/downloads/info.aspx?na=90&p=&SrcDisplayLang=cs&SrcCategoryId=&SrcFamilyId=0856eacb-4362-4b0d-8edd-aab15c5e04f5&u=http%3a%2f%2fdownload.microsoft.com%2fdownload%2f5%2f6%2f7%2f567758a3-759e-473e-bf8f-52154438565a%2fdotnetfx.exe';
// local system for testing...
// dotnetRedistURL = 'http://localhost/dotnetfx.exe';
function InitializeSetup(): Boolean;
begin
Result := true;
dotNetNeeded := false;
// Check for required netfx installation
if (not RegKeyExists(HKLM,
'Software\Microsoft\.NETFramework\policy\v2.0')) then begin
dotNetNeeded := true;
if (not IsAdminLoggedOn()) then begin
MsgBox('App needs the Microsoft .NET Framework to be installed by an
Administrator', mbInformation, MB_OK);
Result := false;
end else begin
memoDependenciesNeeded := memoDependenciesNeeded + ' .NET Framework 2.0'
#13;
dotnetRedistPath := ExpandConstant('{src}\dotnetfx.exe');
if not FileExists(dotnetRedistPath) then begin
dotnetRedistPath := ExpandConstant('{tmp}\dotnetfx.exe');
if not FileExists(dotnetRedistPath) then begin
isxdl_AddFile(dotnetRedistURL, dotnetRedistPath);
downloadNeeded := true;
end;
end;
SetIniString('install', 'dotnetRedist', dotnetRedistPath,
ExpandConstant('{tmp}\dep.ini'));
end;
end;
end;
function NextButtonClick(CurPage: Integer): Boolean;
var
hWnd: Integer;
ResultCode: Integer;
begin
Result := true;
if CurPage = wpReady then begin
hWnd := StrToInt(ExpandConstant('{wizardhwnd}'));
// don't try to init isxdl if it's not needed because it will error on <
ie 3
if downloadNeeded then begin
isxdl_SetOption('label', 'Downloading Microsoft .NET Framework');
isxdl_SetOption('description', 'App needs to install the Microsoft .NET
Framework. Please wait while Setup is downloading extra files to your
computer.');
if isxdl_DownloadFiles(hWnd) = 0 then Result := false;
end;
if (Result = true) and (dotNetNeeded = true) then begin
if Exec(ExpandConstant(dotnetRedistPath), '', '', SW_SHOW,
ewWaitUntilTerminated, ResultCode) then begin
// handle success if necessary; ResultCode contains the exit code
if not (ResultCode = 0) then begin
Result := false;
end;
end else begin
// handle failure if necessary; ResultCode contains the error code
Result := false;
end;
end;
end;
end;
function UpdateReadyMemo(Space, NewLine, MemoUserInfoInfo, MemoDirInfo,
MemoTypeInfo, MemoComponentsInfo, MemoGroupInfo, MemoTasksInfo: String):
String;
var
s: string;
begin
if memoDependenciesNeeded <> '' then s := s + 'Dependencies to install:'
+ NewLine + memoDependenciesNeeded + NewLine;
s := s + MemoDirInfo + NewLine + NewLine;
Result := s
end;
Používej prosím tagu kód takto je to neuvěřitelně nepřehledné.
Ten jsem teď otestoval a ten to taky neumí. Inno to umí, ale dopátral jsem se tohodle kodu, který je prý funkční, ale nechápu kam mám dát tu knihovnu. Sice jsem jí sehnal, ale nevim kam jí mám umístit. Přikládám kod:
var
dotnetRedistPath: string;
downloadNeeded: boolean;
dotNetNeeded: boolean;
memoDependenciesNeeded: string;
procedure isxdl_AddFile(URL, Filename: PChar);
external 'isxdl_AddFile@files:isxdl.dll stdcall';
function isxdl_DownloadFiles(hWnd: Integer): Integer;
external 'isxdl_DownloadFiles@files:isxdl.dll stdcall';
function isxdl_SetOption(Option, Value: PChar): Integer;
external 'isxdl_SetOption@files:isxdl.dll stdcall';
const
dotnetRedistURL = 'http://www.microsoft.com/downloads/info.aspx?na=90&p=&SrcDisplayLang=cs&SrcCategoryId=&SrcFamilyId=0856eacb-4362-4b0d-8edd-aab15c5e04f5&u=http%3a%2f%2fdownload.microsoft.com%2fdownload%2f5%2f6%2f7%2f567758a3-759e-473e-bf8f-52154438565a%2fdotnetfx.exe';
// local system for testing...
// dotnetRedistURL = 'http://localhost/dotnetfx.exe';
function InitializeSetup(): Boolean;
begin
Result := true;
dotNetNeeded := false;
// Check for required netfx installation
if (not RegKeyExists(HKLM, 'Software\Microsoft\.NETFramework\policy\v2.0')) then begin
dotNetNeeded := true;
if (not IsAdminLoggedOn()) then begin
MsgBox('App needs the Microsoft .NET Framework to be installed by an Administrator', mbInformation, MB_OK);
Result := false;
end else begin
memoDependenciesNeeded := memoDependenciesNeeded + ' .NET Framework 2.0' #13;
dotnetRedistPath := ExpandConstant('{src}\dotnetfx.exe');
if not FileExists(dotnetRedistPath) then begin
dotnetRedistPath := ExpandConstant('{tmp}\dotnetfx.exe');
if not FileExists(dotnetRedistPath) then begin
isxdl_AddFile(dotnetRedistURL, dotnetRedistPath);
downloadNeeded := true;
end;
end;
SetIniString('install', 'dotnetRedist', dotnetRedistPath, ExpandConstant('{tmp}\dep.ini'));
end;
end;
end;
function NextButtonClick(CurPage: Integer): Boolean;
var
hWnd: Integer;
ResultCode: Integer;
begin
Result := true;
if CurPage = wpReady then begin
hWnd := StrToInt(ExpandConstant('{wizardhwnd}'));
// don't try to init isxdl if it's not needed because it will error on < ie 3
if downloadNeeded then begin
isxdl_SetOption('label', 'Downloading Microsoft .NET Framework');
isxdl_SetOption('description', 'App needs to install the Microsoft .NET Framework. Please wait while Setup is downloading extra files to your computer.');
if isxdl_DownloadFiles(hWnd) = 0 then Result := false;
end;
if (Result = true) and (dotNetNeeded = true) then begin
if Exec(ExpandConstant(dotnetRedistPath), '', '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then begin
// handle success if necessary; ResultCode contains the exit code
if not (ResultCode = 0) then begin
Result := false;
end;
end else begin
// handle failure if necessary; ResultCode contains the error code
Result := false;
end;
end;
end;
end;
function UpdateReadyMemo(Space, NewLine, MemoUserInfoInfo, MemoDirInfo, MemoTypeInfo, MemoComponentsInfo, MemoGroupInfo, MemoTasksInfo: String): String;
var
s: string;
begin
if memoDependenciesNeeded <> '' then s := s + 'Dependencies to install:' + NewLine + memoDependenciesNeeded + NewLine;
s := s + MemoDirInfo + NewLine + NewLine;
Result := s
end;
Zobrazeno 9 zpráv z 9.