PDA

View Full Version : Product Upgrades and ALLUSERS conflict. Episode II.



Igorendra
11-25-2003, 09:07 AM
I have a problem which was described in the following thread:
http://community.installshield.com/showthread.php?s=&threadid=86299&highlight=peruser+permachine

I have written a script to detect previous per-user installations (see below). But function MsiEnumRelatedProducts does not enumerate product which was installed for a different user.

So, I can check by MsiQueryProductState function what product was installed for a different user if I know its ProductCode, but I cannot get ProductCode by MsiEnumRelatedProducts.

Are there something to resolve this problem? I think direct windows registry reading is bad idea to resolve this problem.

Thanks,
Igorendra.

PS: script:

prototype int Msi.MsiQueryProductStateA(byval string);
prototype int Msi.MsiEnumRelatedProductsA(byval string, byval int, byval int, byref string);

function FindPerUserProducts(hMSI)
NUMBER nvRes;
NUMBER i,nvSize;
STRING ProdCod[50],sUpgrCode[50];
begin
nvSize=50;
if(MsiGetProperty(hMSI,"UpgradeCode", sUpgrCode, nvSize)!=ERROR_SUCCESS) then
MessageBox("FindPerUserProducts function. Cannot get \"UpgradeCode\" property.",SEVERE);
return ERROR_INSTALL_FAILURE;
endif;
i=0;
nvRes2=ERROR_SUCCESS;
while(MsiEnumRelatedProductsA(sUpgrCode,0,i,ProdCod)==ERROR_SUCCESS)
nvRes=MsiQueryProductStateA(ProdCod);
if( nvRes==INSTALLSTATE_ABSENT ) then
MessageBox( "The Setup cannot uninstall existing Product because "+
"it was installed for another user. Please login as that "+
"user and uninstall existing Product, then try to install again.", SEVERE);
return ERROR_INSTALL_FAILURE;
elseif( nvRes==INSTALLSTATE_DEFAULT ) then
MessageBox("Debug: There is Product which was installed for current user.", SEVERE);
endif;
i=i+1;
endwhile;
return ERROR_SUCCESS;
end;