PDA

View Full Version : RegDBGetKeyValue (*&^



parachute
10-17-2003, 06:17 AM
Hi !

I have very hard time with this (^%(^% command. This is what I do :

Product X

sName = "BIN";
sKey = "HKEY_LOCAL_MACHINE\\SOFTWARE\\ABC\\X\\CLIENT\\;
nType = REGDB_STRING;
nSize = -1;

if (RegDBGetKeyValueEx (szKey, sName, nType, szValue, nSize) < 0) then
MessageBox...

and at least, I would like to goto Finish after the error message.

What's wrong ? Is there a better way with table instead InstallScript ?

Thank you !:confused:

RobertDickau
10-17-2003, 08:33 AM
In the sKey argument, leave out the root key (HKEY_LOCAL_MACHINE, in your case) and instead call

RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);

first; please see the RegDBGetKeyValueEx help page for more information and a script sample. (As an aside, it's not necessary to populate the nType variable before calling the function; the function fills out this value so you can determine afterward what data type you just read.)

As an alternative, you could use a system search (using AppSearch and related tables) to populate an MSI property with a value from the registry, which might be simpler, depending on what you want to do with the value.

lsmeteor
10-17-2003, 08:39 AM
Not sure if i understand correctly but I have attached a sample code that I use to retrieve registry values

I don't use it anymore but it works as expected. I developed that from the samples in the help files. There are a lot of comment out lines but play around with them.

This searches for a particular driver installation, then displays a messagebox if not found, or goes on if it does.



function IsPervasiveODBC32Installed(lResult)
// To Do: Declare local variables.

STRING svResult;
STRING szKey, szNumName, szNumValue, svNumValue, sType, szMsg,svVersionNumber;
NUMBER nType, nSize, nvType, nvSize;
STRING svReturnString;

begin

lResult=0;
// Set up parameters for call to RegDBSetKeyValueEx.
RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);

szKey="SOFTWARE\\ODBC\\ODBCINST.INI\\Pervasive Software ODBC-32";
szNumName = "Driver";

// Retrieve key value information.
if (RegDBGetKeyValueEx (szKey, szNumName, nvType, svNumValue, nvSize) < 0) then
// OBDBC not found
lResult = 0;
MessageBox ("Pervasive ODBC Driver registry entry not found.", SEVERE);
else

// Get the full path.
szMsg = "nOperation = PATH\n\nParsed Path: %s";

if (ParsePath (svReturnString, svNumValue, PATH) < 0) then
MessageBox ("ParsePath failed", SEVERE);
endif;


// Get the directory name.
if (ParsePath (svReturnString, szNumName, DIRECTORY) < 0) then
MessageBox ("ParsePath failed", SEVERE);
else
szMsg = "nOperation = DIRECTORY\n\nParsed Path: %s";
SprintfBox (INFORMATION, TITLE_TEXT, szMsg, svReturnString);
endif;


// Display what RegDBGetKeyValueEx retrieved.
// szMsg = "%s has value: %s\n\nThis data is %d bytes.";
// SprintfBox (INFORMATION, "INSTALL", szMsg, szNumName, svNumValue, nvSize);

if (FindFile(svReturnString,"w32btint.dll",svResult)<0) then
// MessageBox (svNumValue + " can not be found.", SEVERE);
//install the ODBC driver
lResult = 0;
else
lResult=1;
// MessageBox("File Found",INFORMATION);
endif;
endif;
return lResult;
end;

parachute
10-17-2003, 08:42 AM
Hi !

The problem is because the base product has to be installed before I install other dll. If the product is not already installed, I have to advise the user and finish the installation.

If the product is install, I have to keep the path where it's install to be able to install my dll in the right path.

Before, I ask if it's client or server and after that verify if it's already install.

I'm presently looking at AppSearch. I try to specify the default path but doesn't work.

Thank you !

parachute
10-17-2003, 09:15 AM
Hi Laurent,

Thank you very much ! It's very appreciate.

parachute
10-17-2003, 11:30 AM
Another thing...

After being able to find the product and the directory, it start copying but always copying at the suggested directory. What's wrong ?

Thank you !

lsmeteor
10-17-2003, 12:18 PM
hm... I never had to do that but I think you have to set the new location value to INSTALLDIR during location screen.
take a look at http://community.installshield.com/showthread.php?s=&threadid=122040&highlight=set+directory

and
http://community.installshield.com/showthread.php?s=&threadid=107010&highlight=set+INSTALLDIR

Maybe you can find what you're looking for :)

parachute
10-17-2003, 12:22 PM
Hi Laurent,

You're so nice.

I found it and you have reason ! Just have to reinitiate INSTALLDIR to the new path.

Thank you very much !

lsmeteor
10-17-2003, 12:37 PM
Pas de probleme my friend ;)