Hi
I using the following code and It works fine for first time installation but when the user uninstall the product the PATH variable will damaged. can anyone give me an ide or tell me what I am doing wrong?
Many thanks...
I tried to move it to a feature installed event but then the PATH Environment Variable is deleted after uninstall
I using the following code and It works fine for first time installation but when the user uninstall the product the PATH variable will damaged. can anyone give me an ide or tell me what I am doing wrong?
Code:
function OnEnd()
#define WM_WININICHANGE 0x001A
#define HWND_BROADCAST 0xffff
NUMBER nResult, nvSize, nvType, nLocation ;
STRING szKey, szEnv, svPath, szFileFound, szStr;
WPOINTER pEnv;
begin
FileRegistration("ScanX.dll");
szEnv = "";
szKey = "SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment";
RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
RegDBGetKeyValueEx(szKey, "Path", nvType, szEnv, nvSize);
nLocation = StrFind ( szEnv , TARGETDIR );
if (nLocation < 0) then
szEnv = szEnv + ";" + TARGETDIR;
nResult = RegDBSetKeyValueEx(szKey, "Path", REGDB_STRING, szEnv, -1);
if (nResult < 0) then
//MessageBox("Failed to Set Environment Variable", WARNING);
else
//MessageBox("Successfully Set Environment Variable", INFORMATION);
// Flush the registry to all applications.
szStr = "Environment";
pEnv = &szStr;
SendMessage (HWND_BROADCAST, WM_WININICHANGE, 0, pEnv );
endif;
// RebootDialog("", "", SYS_BOOTMACHINE);
endif;
end;
I tried to move it to a feature installed event but then the PATH Environment Variable is deleted after uninstall