1、写注册表
lResult = Registry.DoesKeyExist(HKEY_LOCAL_MACHINE, "SOFTWARE\\MapInfo\\MapX\\5.0");
if not lResult then
Registry.CreateKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\MapInfo\\MapX\\5.0");
end;
Registry.SetValue(HKEY_LOCAL_MACHINE, "SOFTWARE\\MapInfo\\MapX\\5.0", "ProgramDir", "C:\\Program Files\\MapInfo\\MapX 5.0", REG_MULTI_SZ);
Registry.SetValue(HKEY_LOCAL_MACHINE, "SOFTWARE\\MapInfo\\MapX\\5.0", "SearchPaths", "", REG_MULTI_SZ);
Registry.SetValue(HKEY_LOCAL_MACHINE, "SOFTWARE\\MapInfo\\MapX\\5.0", "GeoDictionary", "", REG_MULTI_SZ);
Registry.SetValue(HKEY_LOCAL_MACHINE, "SOFTWARE\\MapInfo\\MapX\\5.0", "VersionCode", "5.02", REG_MULTI_SZ);
Registry.SetValue(HKEY_LOCAL_MACHINE, "SOFTWARE\\MapInfo\\MapX\\5.0", "CommonDLLDir", "C:\\Program Files\\MapInfo\\MapX 5.0", REG_MULTI_SZ);
2、注册文件
lreg = SessionVar.Expand('"%AppFolder%\\MapX 5.0\\regsvr32.exe" /s ');
lfile = SessionVar.Expand('"%AppFolder%\\MapX 5.0\\MAPX50.DLL"');
localfile = String.Concat(lreg,lfile);
File.Run(localfile, "", "", SW_SHOWNORMAL, false);
--result = Dialog.Message("注意",localfile, MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
3、检查Oracle客户端是否安装
function isOracleClientInstalled()
retVal = Registry.DoesKeyExist(HKEY_LOCAL_MACHINE, "Software\\Oracle\\HOME0");
-- 提供额外的检查
return retVal;
end;
4、下载文件(s)
function downloadFile(remoteUrl, localFile, title)
retVal = ""
httpOK = HTTP.TestConnection(remoteUrl);
if (httpOK) then
StatusDlg.Show(0, false);
StatusDlg.SetTitle(title);
HTTP.Download(remoteUrl, localFile);
StatusDlg.Hide();
err = Application.GetLastError();
if err == 0 then
return localFile;
end;
end;
if (not httpOK) then
return "";
end;
end;
function downloadFiles(remotePath, files, localPath, title)
StatusDlg.Show(0, false);
StatusDlg.SetTitle(title);
for idx, f in files do
remoteFile = String.Concat(remotePath, f);
localFile = String.Concat(localPath, String.Replace(f, "/", "\\"));
HTTP.Download(remoteFile, localFile);
err = Application.GetLastError();
if err ~= 0 then
return "";
end;
end;
StatusDlg.Hide();
return localPath;
end;
5、添加Oracle连接串
function addOracleLocalService(serviceName, host, port, remoteService)
oraFile = Registry.GetValue(HKEY_LOCAL_MACHINE, "Software\\Oracle", "ORACLE_HOME");
oraFile = String.Concat(oraFile, "\\network\\admin\\tnsnames.ora");
stroraFile = TextFile.ReadToString(oraFile);
svcPos = 1;
oraFileLen = String.Length(stroraFile);
while svcPos > 0 and svcPos < oraFileLen do
svcPos = String.Find(stroraFile, serviceName, svcPos + String.Length(serviceName), false);
if svcPos > 0 and prevIsNotSymbol(stroraFile, svcPos) and nextSymbol(stroraFile, svcPos + String.Length(serviceName), oraFileLen) == '=' then
break;
end;
end;
if svcPos == -1 then
stroraFile =
String.Concat(serviceName,
String.Concat(" =\r\n (DESCRIPTION =\r\n (ADDRESS_LIST =\r\n (ADDRESS = (PROTOCOL = TCP)(HOST = ",
String.Concat(host,
String.Concat(")(PORT = ",
String.Concat(port,
String.Concat("))\r\n )\r\n (CONNECT_DATA =\r\n (SERVICE_NAME = ",
String.Concat(remoteService,
")\r\n )\r\n )"
)
)
)
)
)
)
);
stroraFile = String.Concat("\r\n", stroraFile);
orabakFile = String.Concat(oraFile, ".sbk");
File.Copy(oraFile, orabakFile);
TextFile.WriteFromString(oraFile, stroraFile, true);
end;
end;
6、修改hosts文件
function addSdeLocalHosts(LName,MapIP)
hostsFile = _WindowsFolder;
hostsFile = String.Concat(hostsFile, "\\system32\\drivers\\etc\\hosts");
--Debug.SetTraceMode(turn_on);
--Debug.ShowWindow(true);
--Debug.SetTraceMode(true);
Avar =String.Concat(MapIP," ");
Avar =String.Concat(Avar,LName);
--strhostFile = TextFile.ReadToString(hostsFile);
--strhostFile =String.Concat(strhostFile,Avar);
strhostFile =String.Concat("\r\n",Avar);
-- strhostFile=Avar;
hostsbakFile = String.Concat(hostsFile, ".sbk");
File.Copy(hostsFile, hostsbakFile);
TextFile.WriteFromString(hostsFile,strhostFile, true);
end;
7、检查fromwork2.0是否安装
function isDotNETInstalled()
retVal = Registry.DoesKeyExist(HKEY_LOCAL_MACHINE,
"Software\\Microsoft\\.NETFramework\\Policy\\v2.0");
-- 做额外的检查
return retVal;
end;
8、其它
DlgProgressBar.SetRange(CTRL_PROGRESS_BAR_01, 0, 5);
DlgProgressBar.SetStep(CTRL_PROGRESS_BAR_01, 1);
-- Test if Oracle 9i Client is installed.
-- If not, download from the location specified by session variable "%OracleDownloadUrl%"
-- and install it.
DlgProgressBar.SetProperties(CTRL_PROGRESS_BAR_01, {Text="正在验证Oracle客户端安装..."});
DlgProgressBar.Step(CTRL_PROGRESS_BAR_01);
if not isOracleClientInstalled() then
localOracleStartFolder = SessionVar.Expand("%TempFolder%\\Oracle\\");
localOracle = String.Concat(localOracleStartFolder, "Oracle9iClient.msi");
oracleUrl = SessionVar.Get("%OracleDownloadUrl%");
if downloadFile(oracleUrl, localOracle, "正在下载Oracle客户端……") == localOracle then
runMSINoAttention(localOracle, localOracleStartFolder);
else
Dialog.Message("错误",
"不能下载安装Oracle客户端,安装完本软件后,请自行下载安装。",
MB_OK,
MB_ICONEXCLAMATION);
end;
end;
-- If oracle client does exist or has just been installed, register local oracle service name.
DlgProgressBar.SetProperties(CTRL_PROGRESS_BAR_01, {Text="正在验证Oracle客户端服务名..."});
DlgProgressBar.Step(CTRL_PROGRESS_BAR_01);
if isOracleClientInstalled() then
addOracleLocalService(
SessionVar.Get("%OracleLocalService%"),
SessionVar.Get("%OracleRemoteHost%"),
SessionVar.Get("%OracleRemotePort%"),
SessionVar.Get("%OracleRemoteService%")
);
end;