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.