How to find the ComponentID of the component in MSI programmatically?

Viewed 44

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 .?

1 Answers

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);
Related