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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to delete a list of files from the registry by selection

Status
Not open for further replies.

Amulet

Programmer
Sep 29, 2002
19
MY
hi experts,
i have a list of products listed on the listbox.
when the user select a product and then the button Remove, it will remove the selected product from the registry.

this is my code:

**********************************************************
#define lpRegKey "SOFTWARE\\Microsoft\\Products

int response = 0;

response = MessageBox("Are you sure?", "Delete!", MB_YESNO | MB_ICONQUESTION);

if (response == IDYES) {

SHDeleteKey(HKEY_LOCAL_MACHINE,lpRegKey);

MessageBox("Remove succesful! Please refresh your Registry.","Removed",
MB_OK|MB_ICONEXCLAMATION); }

**********************************************************

The function deletes all the files under Products from the registry. how do i make the program delete only the desired and selected file? please help. thx.


 
It is not clear whether under your key, SOFTWARE\Microsoft\Products, you have the products listed as values or as subkeys.
If they are subkeys, you only have to add to the path the subkey that corresponds to the desired product and only then call SHDeleteKey. Such a key would be:
SOFTWARE\Microsoft\Products\Product1.

If they are values, you will have to call SHDeleteValue() with:
- hKey -> HKEY_LOCAL_MACHINE;
- pszSubKey -> SOFTWARE\Microsoft\Products;
- pszValue -> the name of the value that corresponds to the product (eg Product1).

I hope this is helpful.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top