<DependencyTemplate>
<Dependency>
<Name>Fhash10C</Name>
<RuntimeTempFolder>Flash10</RuntimeTempFolder>
<RevisionDate>Tuesday November 17, 2009</RevisionDate>
<Description>安装 Flash10 应用程序所需的运行时文件。</Description>
<DetectScript>
function isFlash_Installed()
SetupData.WriteToLogFile("Success\t.Flash10 Module: Detection script started.\r\n", true);
-- Get the operating system name.
--Check to see if the registry key exists
--Flash_Registry = Registry.DoesKeyExist(HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Adobe Flash Player ActiveX");
result = File.Find(SessionVar.Expand("%SystemDrive%\\windows\\system32\\Macromed\\flash\\"), "*.exe", true, false);
if (not result) then
-- The registry key does not exist
-- Run the .NET Installation script
-- Output to the log file that .NET could not be found, so it will be installed.
SetupData.WriteToLogFile("Info\t.Flash Module: No version of Flash10 files was found. Flash10 will be installed.\r\n", true);
return false;
else
SetupData.WriteToLogFile("Info\t.Flash Module: A new or this version of Flash10 was found on the users system.\r\n", true);
return true
end
end
</DetectScript>
<DetectFunction>isFlash_Installed</DetectFunction>
<InstallScript>
-- 用在安装操作中的变量:
local strMessage = [[安装程序检测到你的系统没有安装FlashPlayer或者版本过旧。请点击“确定”进行安装,点击“取消”中止安装。]];
local strDialogTitle = "必需的技术文件";
local bShowUserPrompt = true; -- 设置为 true 来询问用户是否安装模块
local bRunInstallFile = true; -- 设置默认选择 (是否默认运行安装)
local strRuntimeSupportFolder = SessionVar.Expand("%TempLaunchFolder%\\Flash10");
local strFileToRun = strRuntimeSupportFolder.."\\flashplayer.exe";
-----------------------------------------------------------------------------------------
-- 安装已启动。
SetupData.WriteToLogFile("成功\Flash10c 模块:安装脚本已启动。\r\n", true);
-- 删除临时文件和运行时支持文件夹 (同时进行错误检查)
local function PerformCleanUp()
File.Delete(strFileToRun);
error = Application.GetLastError();
if error ~= 0 then
SetupData.WriteToLogFile("错误\Flash10c 模块:无法删除临时文件 (".._tblErrorMessages[error]..")\r\n", true);
end
Folder.Delete(strRuntimeSupportFolder);
error = Application.GetLastError();
if error ~= 0 then
SetupData.WriteToLogFile("错误\Flash10c模块:无法删除临时文件夹 (".._tblErrorMessages[error]..")\r\n", true);
end
end
-- 是否显示对话框来询问用户是否安装模块。
if(bShowUserPrompt)then
local nDialogResult = Dialog.Message(strDialogTitle,strMessage,MB_OKCANCEL,MB_ICONEXCLAMATION);
if(nDialogResult == IDOK)then
-- 用户选择安装模块。
bRunInstallFile = true;
-- 用户要安装它
SetupData.WriteToLogFile("成功\Flash10c 模块:用户已确认,准备安装。\r\n", true);
else
-- 用户不安装模块。
bRunInstallFile = false;
-- 用户回答否
SetupData.WriteToLogFile("成功\Flash10c 模块:用户不安装模块。\r\n", true);
end
end
-- 检查用户是否要安装运行时。
if(bRunInstallFile)then
-- 开始!
SetupData.WriteToLogFile("成功\Flash10c模块:正在运行Flash10c 安装程序。\r\n", true);
-- “/R:N”命令行参数告诉 VB 安装程序若需要的话不要显示重启屏幕。
-- 我们将检测整个安装进程返回代码,若需要的话,还设置内部 _NeedsReboot 变量。
-- 【注意】在静默方式下,你不能添加命令行参数“/Q”来运行安装
local nResult = File.Run(strFileToRun,"","",SW_SHOWNORMAL,true);
if(nResult == 3010)then
-- VB 安装指明它需要重启才能完成
-- 设置 Setup Factory 的重启变量,以便在安装结束时重启
_NeedsReboot = true;
-- 需要重启
SetupData.WriteToLogFile("成功\Flash10c 模块:Flash10c 安装程序已告知它需要重启。\r\n", true);
end
-- 删除运行时安装程序文件,并删除临时文件夹
PerformCleanUp();
-- 全部完成!
SetupData.WriteToLogFile("成功\Flash10c模块:Flash10c运行时安装完毕。\r\n", true);
else
-- 用户不想安装运行时,那么删除运行时安装程序文件,
-- 并删除临时文件夹,然后退出安装程序。
PerformCleanUp();
-- 全部完成!
SetupData.WriteToLogFile("成功\Flash10c 模块:Flash10c 运行时未安装。\r\n", true);
Application.Exit();
end
</InstallScript>
<SupportFiles>
<File>#SUFDIR#\Dependencies\Flash10\flashplayer.exe</File>
</SupportFiles>
</Dependency>
</DependencyTemplate>