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

276 Views Asked by At

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

There are 1 best solutions below

1
Vivek Jaiswal On BEST ANSWER

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