TLama

Untitled

May 3rd, 2013
622
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.68 KB | None | 0 0
  1. [Setup]
  2. AppName=My Program
  3. AppVersion=1.5
  4. DefaultDirName={pf}\My Program
  5. InfoBeforeFile=d:\INNOProposal.txt
  6. OutputDir=userdocs:Inno Setup Examples Output
  7.  
  8. [Code]
  9. #IFDEF UNICODE
  10.   #DEFINE AW "W"
  11. #ELSE
  12.   #DEFINE AW "A"
  13. #ENDIF
  14. type
  15.   INSTALLSTATE = Longint;
  16. const
  17.   INSTALLSTATE_INVALIDARG = -2;  // An invalid parameter was passed to the function.
  18.   INSTALLSTATE_UNKNOWN = -1;     // The product is neither advertised or installed.
  19.   INSTALLSTATE_ADVERTISED = 1;   // The product is advertised but not installed.
  20.   INSTALLSTATE_ABSENT = 2;       // The product is installed for a different user.
  21.   INSTALLSTATE_DEFAULT = 5;      // The product is installed for the current user.
  22.  
  23.   VC_2008_SP1_REDIST_X86 = '{9A25302D-30C0-39D9-BD6F-21E6EC160475}';
  24.  
  25. function MsiQueryProductState(szProduct: string): INSTALLSTATE;
  26.   external 'MsiQueryProductState{#AW}@msi.dll stdcall';
  27.  
  28. function InitializeSetup: Boolean;
  29. var
  30.   S: string;
  31.   State: INSTALLSTATE;
  32. begin
  33.   Result := False;
  34.   State := MsiQueryProductState(VC_2008_SP1_REDIST_X86);
  35.   case State of
  36.     INSTALLSTATE_INVALIDARG: S := 'INSTALLSTATE_INVALIDARG: An invalid parameter was passed to the function.';
  37.     INSTALLSTATE_UNKNOWN: S := 'INSTALLSTATE_UNKNOWN: The product is neither advertised or installed.';
  38.     INSTALLSTATE_ADVERTISED: S := 'INSTALLSTATE_ADVERTISED: The product is advertised but not installed.';
  39.     INSTALLSTATE_ABSENT: S := 'INSTALLSTATE_ABSENT: The product is installed for a different user.';
  40.     INSTALLSTATE_DEFAULT: S := 'INSTALLSTATE_DEFAULT: The product is installed for the current user.';
  41.   else
  42.     S := IntToStr(State) + 'Unexpected result';
  43.   end;
  44.   MsgBox(S, mbInformation, MB_OK);
  45. end;
Advertisement
Add Comment
Please, Sign In to add comment