Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need haelp with Registry.vcx 1

Status
Not open for further replies.

MarkButler

Programmer
Feb 22, 2001
83
US
There was a great article published in FoxPro Advisor last month that worked through defining an ODBC driver using a small program and the registry.vcx class. I wish to do the same except that I would like to delete the driver if it exists when the user is having problems and then redefine it.

I was wondering how to delete the ODBC driver. Ther is a "DeleteKey" method in the class which is passed two parameters.

LPARAMETER nUserKey,cKeyPath

I cant seem to find any documentation as to what these parameters are and I ma afraid to just start experimenting and corrupt the registry.

Any help would be appreciated. TIA
 
Mark,

Run search in your Windows folder for the files *.dat containing text "HKEY_". Thus you will know what registry files you've got. Save them somewhere as a backup copy and then you can experiment with registry.

HTH.

Regards,

Ilya
 
MarkButler,

Take the code below and cut-n-paste it into a prg file and run it:

#DEFINE HKEY_CLASSES_ROOT -2147483648 && BITSET(0,31)
#DEFINE HKEY_CURRENT_USER -2147483647 && BITSET(0,31)+1
#DEFINE HKEY_LOCAL_MACHINE -2147483646 && BITSET(0,31)+2
#DEFINE HKEY_USERS -2147483645 && BITSET(0,31)+3

PUBLIC oRegistry

oRegistry = newobject("registry",HOME()+"ffc\registry.vcx")
IF oRegistry.OpenKey("Software\MyNewHopefullyUniqueKey\123456", HKEY_CURRENT_USER,.T.) = 0

=oRegistry.CloseKey()

IF oregistry.setregkey("I_HOPE_YOU_DONT_HAVE_A_VALUE_NAMED_THIS", ;
"somedataforthis", ;
"Software\MyNewHopefullyUniqueKey\123456\", ;
HKEY_CURRENT_USER) != 0

MESSAGEBOX("Sorry error setting the registry value!",48)
RETURN
ENDIF

MESSAGEBOX("Regedit will run while I wait for you to go see your new value" + ;
CHR(13) + "Look under the HKEY_CURRENT_USER hive and click on the Software key..." +;
CHR(13) + "then click on MyNewHopefullyUniqueKey key and look to the right and you should see " +;
"I_HOPE_YOU_DONT_HAVE_A_VALUE_NAMED_THIS")

RUN /n regedit

MESSAGEBOX("Are you done looking and want me to delete it?")

IF oRegistry.DeleteKeyValue("I_HOPE_YOU_DONT_HAVE_A_VALUE_NAMED_THIS", ;
"Software\MyNewHopefullyUniqueKey\123456\", ;
HKEY_CURRENT_USER) != 0
MESSAGEBOX("Sorry error deleting the registry value I_HOPE_YOU_DONT_HAVE_A_VALUE_NAMED_THIS!",48)
RETURN
ENDIF

MESSAGEBOX("Now that we've deteleted the value, lets delete the 2 new keys")

IF oRegistry.DeleteKey(HKEY_CURRENT_USER,"Software\MyNewHopefullyUniqueKey\123456") != 0
MESSAGEBOX("Sorry error deleting the registry key 123456!",48)
ELSE
IF oRegistry.DeleteKey(HKEY_CURRENT_USER,"Software\MyNewHopefullyUniqueKey") != 0
MESSAGEBOX("Sorry error deleting the registry key MyNewHopefullyUniqueKey!",48)
endif
RETURN
ENDIF
ELSE
MESSAGEBOX("We weren't able to create and open the new key",48)
ENDIF

Slighthaze = NULL
 
Great example of deleting a keys value, but waht I am looking to do is delete the actual key.

For instance I have:

HKEY_LOCAL_MACHINE/SOFTWARE/ODBC/ODBC.INI/DSNXXX

Now DSNXXX is the key with the ODBC key names/values under it. I want to delete the key DSNXXX and all the names/values under it. What I am having a problem with is that the parameter to the DeleteKey method is expecting a number for parameter 1 and a key path for parameter two.

I assume that the call will look like the following, just what do I use for parm1.

IF NOT loReg.DeleteKey(lnWhat2Use,'HKEY_LOCAL_MACHINE/SOFTWARE/ODBC/ODBC.INI/DSNXXX')
WAIT WINDOW 'FAILED'
RETURN
ENDIF
 
Sorry, the previous post was right on. If I could only type... Thanx for you assistance, you get a big star.
 
MarkButler,

Thanks for the star, I am glad I could help.

Slighthaze = NULL
 
A real quick side note (you may already know this):

if you run: MODIFY COMMAND HOME() + "ffc\registry.h"

in your command window you should see all of the Define statements for the registry.vcx class library. If it doesn't come up then just search your hard drive for registry.h and open it.

Slighthaze = NULL
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top