[code]function InitializeSetup: Boolean;
var Path:
string
;
ResultCode: Integer;
dotNetV4RegPath:
string
;
dotNetV4DownUrl:
string
;
dotNetV4PackFile:
string
;
wic:
string
;
begin
dotNetV4RegPath:=
'SOFTWARE\Microsoft\.NETFramework\policy\v4.0'
;
dotNetV4DownUrl:=
'http://download.microsoft.com/download/9/5/A/95A9616B-7A37-4AF6-BC36-D6EA96C8DAAE/dotNetFx40_Full_x86_x64.exe'
;
dotNetV4PackFile:=
'{src}\update\dotNetFx40_Full_x86_x64.exe'
;
wic:=
'{src}\update\wic_x86_chs.exe'
;
if
RegKeyExists(HKLM, dotNetV4RegPath) then
begin
Result :=
true
;
end
else
begin
Exec(ExpandConstant(wic),
'/q /norestart'
,
''
, SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode);
if
MsgBox(
'系統檢測到您沒有安裝.Net Framework4.0運作環境,是否立即安裝?'
, mbConfirmation, MB_YESNO) = idYes then
begin
Path := ExpandConstant(dotNetV4PackFile);
if
(FileOrDirExists(Path)) then
begin
Exec(Path,
'/q /norestart'
,
''
, SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode);
if
RegKeyExists(HKLM, dotNetV4RegPath) then
begin
Result :=
true
;
end
else
begin
MsgBox(
'未能成功安裝.Net Framework4.0運作環境,系統将無法運作,本安裝程式即将退出!'
,mbInformation,MB_OK);
end
end
else
begin
if
MsgBox(
'軟體安裝目錄中沒有包含.Net Framework的安裝程式,是否立即下載下傳後安裝?'
, mbConfirmation, MB_YESNO) = idYes then
begin
Path := ExpandConstant(
'{pf}\Internet Explorer\iexplore.exe'
);
Exec(Path, dotNetV4DownUrl ,
''
, SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode);
MsgBox(
'請安裝好.Net Framework4.0環境後,再運作本安裝包程式!'
,mbInformation,MB_OK);
Result :=
false
;
end
else
begin
MsgBox(
'不下載下傳安裝.Net Framework4.0運作環境,系統将無法運作,本安裝程式即将退出!'
,mbInformation,MB_OK);
Result :=
false
;
end
end
end
else
begin
MsgBox(
'沒有安裝.Net Framework4.0運作環境,系統将無法運作,本安裝程式即将退出!'
,mbInformation,MB_OK);
Result :=
false
;
end;
end;
end;