Requirement is to delete few components during uninstallation programmatically. This also requires to delete the registry associated with the components . How to find the ComponentID of the component programmatically, in order to search in the registries .?
Asked
Active
Viewed 183 times
1
-
on which basis you want to search for component id? Do you have component name or anything? – Vivek Jaiswal Sep 08 '22 at 08:16
-
Yes I do have the component name . Using component name is it possible to retrieve the component ID ? – S_1 Sep 08 '22 at 09:43
-
Yes. You can easily retrieve component table. – Vivek Jaiswal Sep 08 '22 at 10:06
-
1Old components will be automatically removed on upgrade if you design your MSI correctly. You must not mess around in the MSI database in the registry. This can cause total corruption of your whole PC. There are cases when you have problems with old install that won't uninstall or upgrade due to runtime errors. In these cases [there are a few methods you can use to deal with it](https://stackoverflow.com/a/53876981/129130). – Stein Åsmul Sep 08 '22 at 17:03
1 Answers
0
You can retrieve component table to fetch componentIds. Here is the installscript code:
hDB = MsiGetActiveDatabase(hMSI);
// open view into Component table
MsiDatabaseOpenView(hDB, "SELECT 'ComponentId' FROM `Component` WHERE `Component`='<Component_name>'", hViewlist);
MsiViewExecute(hViewlist, NULL);
while (MsiViewFetch(hViewlist, hRecordlist) = ERROR_SUCCESS)
// perform your operations
endwhile;
MsiViewClose(hViewlist);

Vivek Jaiswal
- 861
- 1
- 7
- 20