Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inno setup: detect installation based on product code

Tags:

inno-setup

I want to achieve something similar to Inno setup - skip installation if other program is not installed

But I do have the msiexec product code (like D3AA40C4-9BFB-4640-88CE-EDC93A3703CC). So how to detect if another program is installed based on this product code?

like image 576
ElkeAusBerlin Avatar asked Jan 01 '26 07:01

ElkeAusBerlin


1 Answers

There is the MsiQueryProductState function for this. Here is its import with a helper function for your task:

[Code]
#IFDEF UNICODE
  #DEFINE AW "W"
#ELSE
  #DEFINE AW "A"
#ENDIF
type
  INSTALLSTATE = Longint;
const
  INSTALLSTATE_DEFAULT = 5;

function MsiQueryProductState(szProduct: string): INSTALLSTATE; 
  external 'MsiQueryProductState{#AW}@msi.dll stdcall';

function IsProductInstalled(const ProductID: string): Boolean;
begin
  Result := MsiQueryProductState(ProductID) = INSTALLSTATE_DEFAULT;
end;

And its possible usage:

if IsProductInstalled('{D3AA40C4-9BFB-4640-88CE-EDC93A3703CC}') then
  MsgBox('The product is installed.', mbInformation, MB_OK);
like image 129
TLama Avatar answered Jan 06 '26 10:01

TLama



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!