PDA

View Full Version : RegDBGetKeyValueEx fails



badboyz
11-18-2004, 12:01 PM
I want to stop the Installer re-running once a version of the application exist. I have created a Registry Key version which correctly stores the verion number in OnFirstUIBefore. Once I try to pick up using the function RegDBGetKeyValueEx in OnBegin it fails.

Also how can I limit this excercise to ONLY the INSTALL action.

****SNIP FROM OnFirstUIBefore****
//Set up Registry Keys Root
RegDBSetDefaultRoot( HKEY_LOCAL_MACHINE );
szKey = "SOFTWARE\\" + "JavaSoft\\" + "Prefs\\" + "myapp\\" + "app\\";
RegDBCreateKeyEx( szKey, ""

//Store Registry Keys
/*Installation Directory*/
RegDBSetKeyValueEx( szKey, "install_dir", REGDB_STRING, TARGETDIR, -1 );
GetSystemInfo(DATE, nvResult,svResult);
/*Installation Date*/
RegDBSetKeyValueEx( szKey, "install_date", REGDB_STRING, svResult, -1 );
/*Application Licence*/
RegDBSetKeyValueEx( szKey, "appl", REGDB_STRING, "", -1 );
/*Length/ Duration of Application Licence */
RegDBSetKeyValueEx( szKey, "length", REGDB_STRING, "", -1 );

RegDBSetKeyValueEx( szKey, "version", REGDB_STRING, IFX_PRODUCT_VERSION, -1 );



****SNIP FROM ONBEGIN*****
//Set up parameters for call to RegDBSetKeyValueEx.
RegDBSetDefaultRoot( HKEY_LOCAL_MACHINE );
szKey = "SOFTWARE\\" + "JavaSoft\\" + "Prefs\\" + "myapp\\" + "app\\";
szNumName = "version";
nType = REGDB_STRING;
nSize = -1;

// Retrieve key value information.
if (RegDBGetKeyValueEx (szKey, szNumName, nType, svNumValue,
nvSize) < 0) then
//Install Software
else
//TODO hard coded version - should retrieve from registry
if (IFX_PRODUCT_VERSION == szNumValue) then
MessageBox("The Installer has determined that you already have this version
of LaMIS CD installed. " +
"Please uninstall the product through your add/remove
programs utility before reinstalling.", WARNING );
abort;
endif;
endif;

faheemtahir
12-18-2004, 07:05 AM
You can use reference from following code. simply type "abort;" if your condition is not met ;)

following code searches specific jdk version exists or not

if (RegDBSetDefaultRoot(nRootKey) >= 0) then

RegDBGetKeyValueEx( "SOFTWARE\\JavaSoft\\Java Development Kit","CurrentVersion", nTemp, nIEVersion,nSize );

//Remove Fractional Point From Version

nList = ListCreate ( STRINGLIST );
StrGetTokens ( nList, nIEVersion, "." );
nRes = ListGetFirstString (nList, nMsg);
while (nRes != END_OF_LIST)
nVal = nVal + nMsg;
nRes = ListGetNextString (nList, nMsg);
endwhile;

StrToNum( nJDKVer,nVal);

if(nJDKVer >= 15) then
bJDK = TRUE ; //Required JDK Found
else
bJDK = FALSE; //Required JDK Not Found
endif;

RobertDickau
12-19-2004, 11:55 AM
(As an aside, you might find the VerCompare function to be of use.)