要指定数据库文件的路径,但是文件放在用户选择的安装路径中,不是一个固定的路径,如C;\Program Files\MyApplication\MyData.db,这个路径由用户安装的时候选择,在做安装程序的时候不能确定,怎么解决?
function OnEnd()
STRING RegStr;
STRING szAppPath;
STRING szKey,szClass;
STRING szPath,szValue,svOS;
NUMBER nvSize,nvType;
NUMBER nvOS;
begin
szKey = "Software\\ODBC\\ODBCINST.INI\\Adaptive Server Anywhere 7.0";
szClass = "";
szAppPath = TARGETDIR ;
nvSize = -1;
szValue = "path" ;
if !MAINTENANCE then
RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE) ;
if (RegDBKeyExist(szKey) != 1) then
if(RegDBCreateKeyEx(szKey,szClass) < 0) then
MessageBox ("不能创建注册表,请检查您的注册表", SEVERE);
abort;
endif;
endif;
RegDBSetKeyValueEx(szKey,"Driver",REGDB_STRING,szAppPath ^ "\\dll\\dbodbc7.dll",-1);
RegDBSetKeyValueEx(szKey,"Setup",REGDB_STRING,szAppPath ^ "\\dll\\dbodbc7.dll",-1);
szKey = "software\\ODBC\\ODBCINST.INI\\ODBC Drivers";
if (RegDBKeyExist(szKey) != 1) then
if(RegDBCreateKeyEx(szKey,szClass) < 0) then
MessageBox ("不能创建注册表,请检查您的注册表", SEVERE);
abort;
endif;
endif;
RegDBSetKeyValueEx(szKey,"Adaptive Server Anywhere 7.0",REGDB_STRING,"Installed",-1);
//RegDBCreateKeyEx("software\\Enetop",szClass) ;
//RegDBCreateKeyEx("software\\Enetop\\运费结算",szClass) ;
//RegDBCreateKeyEx("software\\Enetop\\运费结算\\1.00.000",szClass) ;
RegDBSetKeyValueEx("software" + "\\" + @COMPANY_NAME + "\\" + @PRODUCT_NAME + "\\" + @PRODUCT_VERSION,"Path",REGDB_STRING,TARGETDIR,-1);
//判断是否是NT还是9x
GetSystemInfo(OS,nvOS,svOS);
if (nvOS = IS_WINDOWSNT) then
RegDBGetKeyValueEx("SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment",szValue,nvType,szPath,nvSize);
if (StrLength(szPath) = 0) then
szPath = szAppPath + "\\dll";
else
if(StrFind(szPath,szAppPath + "\\dll") < 0) then
szPath = szPath + ";" + szAppPath + "\\dll";
endif;
endif;
RegDBSetKeyValueEx("SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment","path",REGDB_STRING,szPath,-1);
RegDBSetDefaultRoot(HKEY_CURRENT_USER) ;
RegDBGetKeyValueEx("Environment",szValue,nvType,szPath,nvSize);
if (StrLength(szPath) = 0) then
szPath = szAppPath + "\\dll";
else
if(StrFind(szPath,szAppPath + "\\dll") < 0) then
szPath = szPath + ";" + szAppPath + "\\dll";
endif;
endif;
RegDBSetKeyValueEx("Environment","path",REGDB_STRING,szPath,-1);
endif;
if (nvOS = IS_WINDOWS9X) then
BatchFileLoad ("C:\\autoexec.bat") ;
szPath = szAppPath + "\\dll";
BatchAdd ("PATH", szPath, "PATH", AFTER);
BatchFileSave("C:\\autoexec.bat") ;
endif;
RebootDialog ("重新启动系统", "", SYS_BOOTMACHINE);
endif;
end;