' ########################################################################################
' Microsoft Windows
' File: appmgmt.inc
' Contents: APIs for operations on MSI applications which are deployed and managed in the NT Directory.
' Copyright (c) 2011 Jos? Roca
' Portions Copyright (c) Microsoft Corporation.
' All Rights Reserved.
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
' EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
' MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
' ########################################################################################
#IF NOT %DEF(PBX_appmgmt_PBI)
#DEFINE PBX_appmgmt_PBI
%EQUATE `APPMGMT_INC = 1
'typedef enum _INSTALLSPECTYPE
'{
' APPNAME = 1,
' FILEEXT,
' PROGID,
' COMCLASS
'} INSTALLSPECTYPE;
%EQUATE `INSTALLSPECTYPE_APPNAME = 1
%EQUATE `INSTALLSPECTYPE_FILEEXT = 2
%EQUATE `INSTALLSPECTYPE_PROGID = 3
%EQUATE `INSTALLSPECTYPE_COMCLASS = 4
TYPE INSTALLSPEC_AppName DWORD
 Name AS WSTRINGZ PTR ' WCHAR * Name
 GPOId AS GUID ' GUID GPOId
END TYPE
TYPE INSTALLSPEC_COMClass DWORD
 Clsid AS GUID
 ClsCtx AS DWORD
END TYPE
UNION INSTALLSPEC DWORD
 INSTALLSPEC_AppName
 FileExt AS WSTRINGZ PTR ' WCHAR * FileExt
 ProgId AS WSTRINGZ PTR ' WCHAR * ProgId
 INSTALLSPEC_COMClass
END UNION
' // Size = 24 bytes
TYPE INSTALLDATA DWORD
 Type AS LONG ' INSTALLSPECTYPE Type
 Spec AS INSTALLSPEC ' INSTALLSPEC Spec
END TYPE
'typedef enum
'{
' ABSENT,
' ASSIGNED,
'} APPSTATE;
%EQUATE `APPSTATE_ABSENT = 0
%EQUATE `APPSTATE_ASSIGNED = 1
%EQUATE `APPSTATE_PUBLISHED = 2
%EQUATE `LOCALSTATE_ASSIGNED = &H1 ' // app is assigned
%EQUATE `LOCALSTATE_PUBLISHED = &H2 ' // app is published
%EQUATE `LOCALSTATE_UNINSTALL_UNMANAGED = &H4 ' // uninstall any unmanaged version before assigning
%EQUATE `LOCALSTATE_POLICYREMOVE_ORPHAN = &H8 ' // app is orphaned when policy removed
%EQUATE `LOCALSTATE_POLICYREMOVE_UNINSTALL = &H10 ' // app is uninstalled when policy removed
%EQUATE `LOCALSTATE_ORPHANED = &H20 ' // app is orphaned after being applied
%EQUATE `LOCALSTATE_UNINSTALLED = &H40 ' // app is uninstalled after being applied
' // Size = 16 bytes
TYPE LOCALMANAGEDAPPLICATION DWORD
 pszDeploymentName AS WSTRINGZ PTR
 pszPolicyName AS WSTRINGZ PTR
 pszProductId AS WSTRINGZ PTR
 dwState AS DWORD
END TYPE
%EQUATE `MANAGED_APPS_USERAPPLICATIONS = &H1
%EQUATE `MANAGED_APPS_FROMCATEGORY = &H2
%EQUATE `MANAGED_APPS_INFOLEVEL_DEFAULT = &H10000
%EQUATE `MANAGED_APPTYPE_WINDOWSINSTALLER = &H1
%EQUATE `MANAGED_APPTYPE_SETUPEXE = &H2
%EQUATE `MANAGED_APPTYPE_UNSUPPORTED = &H3
' // Size = 88 bytes
TYPE MANAGEDAPPLICATION DWORD
 pszPackageName AS WSTRINGZ PTR
 pszPublisher AS WSTRINGZ PTR
 dwVersionHi AS DWORD
 dwVersionLo AS DWORD
 dwRevision AS DWORD
 GpoId AS GUID ' GUID
 pszPolicyName AS WSTRINGZ PTR
 ProductId AS GUID ' GUID
 Language AS WORD ' LANGID
 pszOwner AS WSTRINGZ PTR
 pszCompany AS WSTRINGZ PTR
 pszComments AS WSTRINGZ PTR
 pszContact AS WSTRINGZ PTR
 pszSupportUrl AS WSTRINGZ PTR
 dwPathType AS DWORD
 bInstalled AS LONG
END TYPE
' // Size = 24 bytes
TYPE APPCATEGORYINFO DWORD
 Locale AS DWORD ' LCID
 pszDescription AS WSTRINGZ PTR
 AppCategoryId AS GUID ' GUID
END TYPE
' // Size = 8 bytes
TYPE APPCATEGORYINFOLIST DWORD
 cCategory AS DWORD
 pCategoryInfo AS DWORD ' APPCATEGORYINFO PTR
END TYPE
DECLARE FUNCTION InstallApplication LIB "advapi32.dll" ALIAS "InstallApplication" ( BYREF pInstallInfo AS INSTALLDATA ) AS QUAD
DECLARE FUNCTION UninstallApplication LIB "advapi32.dll" ALIAS "UninstallApplication" ( BYREF ProductCode AS WSTRINGZ
 , BYVAL dwStatus AS DWORD
 ) AS DWORD
DECLARE FUNCTION CommandLineFromMsiDescriptor LIB "advapi32.dll" ALIAS "CommandLineFromMsiDescriptor" ( BYREF Descriptor AS WSTRINGZ
 , BYREF CommandLine AS WSTRINGZ
 , BYVAL CommandLineLength AS DWORD
 ) AS DWORD
DECLARE FUNCTION GetManagedApplications LIB "advapi32.dll" ALIAS "GetManagedApplications" ( BYREF pCategory AS GUID
 , BYVAL dwQueryFlags AS DWORD
 , BYVAL dwInfoLevel AS DWORD
 , BYREF pdwApps AS DWORD
 , BYREF prgManagedApps AS MANAGEDAPPLICATION
 ) AS DWORD
DECLARE FUNCTION GetLocalManagedApplications LIB "advapi32.dll" ALIAS "GetLocalManagedApplications" ( BYVAL bUserApps AS LONG
 , BYREF pdwApps AS DWORD
 , BYREF prgLocalApps AS MANAGEDAPPLICATION
 ) AS DWORD
DECLARE FUNCTION GetLocalManagedApplicationData LIB "advapi32.dll" ALIAS "GetLocalManagedApplicationData" ( BYREF ProductCode AS WSTRINGZ
 , BYREF DisplayName AS DWORD
 , BYREF SupportUrl AS DWORD
 ) AS DWORD
DECLARE FUNCTION GetManagedApplicationCategories LIB "advapi32.dll" ALIAS "GetManagedApplicationCategories" ( BYVAL dwReserved AS DWORD
 , BYREF pAppCategory AS APPCATEGORYINFOLIST
 ) AS DWORD
#ENDIF
