Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

Environment Variables not reflecting in install


1 reply to this topic

clareb22

clareb22
  • Members
  • 20 posts

Posted 19 August 2003 - 09:06

My install needs to update Path with 2 locations, [installdir]\lib and [installdir]\[product name]\lib. I've been able to successfully update environment variables with these paths. Once I have done this and after the files have been installed on the target machine. I need to register certain DLL's, by calling the LaunchApp command with cmd.exe. This works fine with DLL's that have no dependencies, however, when trying to register other dll's (which do have dependencies), I receive a LoadLibrary error. However, if I register the DLL's outside of Installshield i.e. via the command line they register fine.

I'm really stuck and have tried all sorts of possibilities but still can't get it to work, can anyone offer any possible suggestions, or alternative methods of doing this.

The code I am using for setting the environment variables and broadcasting the change is as below:
export prototype ModEnvVarAppend (BOOL, STRING, string, int);
export prototype ModEnvVarRestore (BOOL, STRING, string, int);
#define WM_WININICHANGE 0x001A
#define HWND_BROADCAST 0xffff
NUMBER nResult;
STRING szKey, szEnv;
POINTER pEnv;
string szCurrentVal;
number nType, nSize;
int iValPosition;

function ModEnvVarAppend (bAllUsers, szEnvVar, szValue, iPosition )

string szCurrentVal, szString;

begin
if (SYSINFO.WINNT.bWin2000) then
Disable(LOGGING);
szKey = "SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment";

szString = TARGETDIR^"Lib";

if (StrFind(szCurrentVal, szString)<0)then

else
szValue = TARGETDIR^IFX_PRODUCT_NAME^"Lib";
endif;

if bAllUsers = TRUE then
RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
else
RegDBSetDefaultRoot(HKEY_CURRENT_USER);
endif;

RegDBGetKeyValueEx(szKey, szEnvVar, nType, szCurrentVal, nSize);
iValPosition = StrFind (szCurrentVal, szValue);

if iValPosition < 0 then
// Store string that is being appended in the log file
TextSub( "szEnvVar" ) = szEnvVar;
TextSub( "szValue" ) = szValue;
TextSub( "bAllUsers" ) = bAllUsers;
TextSub( "iPosition" ) = iPosition;
//-------------------------------------
if iPosition = AFTER then
szValue = szCurrentVal + ";" + szValue;
else
szValue = szValue + ";" + szCurrentVal;
endif;

nResult = RegDBSetKeyValueEx(szKey, szEnvVar, nType, szValue, -1);
if (nResult < 0) then
Enable(LOGGING);
return -1;
else
// Flush the NT registry to all applications.
szEnv = "Environment";
pEnv = &szEnv;
SendMessage (HWND_BROADCAST, WM_WININICHANGE, 0, pEnv );
endif;

endif;
Enable(LOGGING);
endif;
return 0;
end;

Edited by clareb22, 19 August 2003 - 09:07.

Many thanks[br]Clare

vuttex

vuttex
  • Full Members
  • 35 posts

Posted 25 August 2003 - 09:15

I have had the same problem as you describe. The HWND_BROADCAST does not always work as a sollution. My workaround is to create a bat file, set the environment variables in it and run regsvr32 in it as well. The other way you can solve this is to register the files after a reboot.