using System; using System.Runtime.InteropServices; using System.Text; using static Vanara.PInvoke.Crypt32; namespace Vanara.PInvoke { /// Items from the Msi.dll public static partial class Msi { /// /// The MsiExtractPatchXMLData function extracts information from a patch that can be used to determine if the patch applies /// to a target system. The function returns an XML string that can be provided to MsiDeterminePatchSequence and /// MsiDetermineApplicablePatches instead of the full patch file. The returned information can be used to determine whether the /// patch is applicable. /// /// /// The full path to the patch that is being queried. Pass in as a null-terminated string. This parameter cannot be NULL. /// /// A reserved argument that must be 0 (zero). /// /// /// A pointer to a buffer to hold the XML string that contains the extracted patch information. This buffer should be large enough /// to contain the received information. If the buffer is too small, the function returns ERROR_MORE_DATA and sets *pcchXMLData to /// the number of TCHAR in the value, not including the terminating NULL character. /// /// /// If szXMLData is set to NULL and pcchXMLData is set to a valid pointer, the function returns ERROR_SUCCESS and sets /// *pcchXMLData to the number of TCHAR in the value, not including the terminating NULL character. The function can then be /// called again to retrieve the value, with szXMLData buffer large enough to contain *pcchXMLData + 1 characters. /// /// /// /// /// A pointer to a variable that specifies the number of TCHAR in the szXMLData buffer. When the function returns, this /// parameter is set to the size of the requested value whether or not the function copies the value into the specified buffer. The /// size is returned as the number of TCHAR in the requested value, not including the terminating null character. /// /// If this parameter is set to NULL, the function returns ERROR_INVALID_PARAMETER. /// /// /// The MsiExtractPatchXMLData function can return the following values. /// /// /// Return code /// Description /// /// /// ERROR_FUNCTION_FAILED /// The function failed in a way that is not identified by any of the return values in this table. /// /// /// ERROR_INVALID_PARAMETER /// An invalid parameter was passed to the function. /// /// /// ERROR_MORE_DATA /// The value does not fit in the provided buffer. /// /// /// ERROR_PATCH_OPEN_FAILED /// The patch file could not be opened. /// /// /// ERROR_SUCCESS /// The function was successful. /// /// /// ERROR_PATCH_PACKAGE_INVALID /// The patch file could not be opened. /// /// /// ERROR_CALL_NOT_IMPLEMENTED /// This error can be returned if MSXML 3.0 is not installed. /// /// /// /// The ExtractPatchXMLData method of the Installer object uses the MsiExtractPatchXMLData function. // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msiextractpatchxmldataa UINT MsiExtractPatchXMLDataA( LPCSTR // szPatchPath, DWORD dwReserved, LPSTR szXMLData, LPDWORD pcchXMLData ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiExtractPatchXMLDataA")] public static extern Win32Error MsiExtractPatchXMLData([MarshalAs(UnmanagedType.LPTStr)] string szPatchPath, [Optional] uint dwReserved, [Out, Optional, MarshalAs(UnmanagedType.LPTStr)] StringBuilder szXMLData, ref uint pcchXMLData); /// /// The MsiGetComponentPath function returns the full path to an installed component. If the key path for the component is a /// registry key then the registry key is returned. /// /// Specifies the product code for the client product. /// Specifies the component ID of the component to be located. /// /// /// Pointer to a variable that receives the path to the component. This parameter can be null. If the component is a registry key, /// the registry roots are represented numerically. If this is a registry subkey path, there is a backslash at the end of the Key /// Path. If this is a registry value key path, there is no backslash at the end. For example, a registry path on a 32-bit operating /// system of HKEY_CURRENT_USER\ SOFTWARE\ Microsoft is returned as "01:\SOFTWARE\Microsoft". The registry /// roots returned on 32-bit operating systems are defined as shown in the following table. /// /// /// Note On 64-bit operating systems, a value of 20 is added to the numerical registry roots in this table to distinguish /// them from registry key paths on 32-bit operating systems. For example, a registry key path of HKEY_CURRENT_USER\ /// SOFTWARE\ Microsoft is returned as "21:\SOFTWARE\Microsoft\", if the component path is a registry key on a 64-bit /// operating system. /// /// /// /// Root /// Meaning /// /// /// HKEY_CLASSES_ROOT /// 00 /// /// /// HKEY_CURRENT_USER /// 01 /// /// /// HKEY_LOCAL_MACHINE /// 02 /// /// /// HKEY_USERS /// 03 /// /// /// /// /// /// Pointer to a variable that specifies the size, in characters, of the buffer pointed to by the lpPathBuf parameter. On input, /// this is the full size of the buffer, including a space for a terminating null character. If the buffer passed in is too small, /// the count returned does not include the terminating null character. /// /// If lpPathBuf is null, pcchBuf can be null. /// /// /// The MsiGetComponentPath function returns the following values. /// /// /// Value /// Meaning /// /// /// INSTALLSTATE_NOTUSED /// The component being requested is disabled on the computer. /// /// /// INSTALLSTATE_ABSENT /// The component is not installed. /// /// /// INSTALLSTATE_INVALIDARG /// One of the function parameters is invalid. /// /// /// INSTALLSTATE_LOCAL /// The component is installed locally. /// /// /// INSTALLSTATE_SOURCE /// The component is installed to run from source. /// /// /// INSTALLSTATE_SOURCEABSENT /// The component source is inaccessible. /// /// /// INSTALLSTATE_UNKNOWN /// The product code or component ID is unknown. /// /// /// /// /// Upon success of the MsiGetComponentPath function, the pcchBuf parameter contains the length of the string in lpPathBuf. /// The MsiGetComponentPath function might return INSTALLSTATE_ABSENT or INSTALL_STATE_UNKNOWN, for the following reasons: /// /// /// INSTALLSTATE_ABSENT /// /// The application did not properly ensure that the feature was installed by calling MsiUseFeature and, if necessary, MsiConfigureFeature. /// /// /// /// INSTALLSTATE_UNKNOWN /// /// The feature is not published. The application should have determined this earlier by calling MsiQueryFeatureState or /// MsiEnumFeatures. The application makes these calls while it initializes. An application should only use features that are known /// to be published. Since INSTALLSTATE_UNKNOWN should have been returned by MsiUseFeature as well, either MsiUseFeature was not /// called, or its return value was not properly checked. /// /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msigetcomponentpatha INSTALLSTATE MsiGetComponentPathA( LPCSTR // szProduct, LPCSTR szComponent, LPSTR lpPathBuf, LPDWORD pcchBuf ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiGetComponentPathA")] public static extern INSTALLSTATE MsiGetComponentPath([MarshalAs(UnmanagedType.LPTStr)] string szProduct, [MarshalAs(UnmanagedType.LPTStr)] string szComponent, [Out, Optional, MarshalAs(UnmanagedType.LPTStr)] StringBuilder lpPathBuf, ref uint pcchBuf); /// /// /// The MsiGetComponentPathEx function returns the full path to an installed component. If the key path for the component is /// a registry key then the function returns the registry key. /// /// /// This function extends the existing MsiGetComponentPath function to enable searches for components across user accounts and /// installation contexts. /// /// /// /// A null-terminated string value that specifies an application's product code GUID. The function gets the path of installed /// components used by this application. /// /// /// A null-terminated string value that specifies a component code GUID. The function gets the path of an installed component having /// this component code. /// /// /// /// A null-terminated string value that specifies the security identifier (SID) for a user in the system. The function gets the /// paths of installed components of applications installed under the user accounts identified by this SID. The special SID string /// s-1-1-0 (Everyone) specifies all users in the system. If this parameter is NULL, the function gets the path of an /// installed component for the currently logged-on user only. /// /// /// /// SID type /// Meaning /// /// /// NULL /// Specifies the currently logged-on user. /// /// /// User SID /// Specifies a particular user in the system. An example of an user SID is "S-1-3-64-2415071341-1358098788-3127455600-2561". /// /// /// s-1-1-0 /// Specifies all users in the system. /// /// /// /// Note The special SID string s-1-5-18 (System) cannot be used to search applications installed in the per-machine /// installation context. Setting the SID value to s-1-5-18 returns ERROR_INVALID_PARAMETER. When dwContext is set to /// MSIINSTALLCONTEXT_MACHINE only, szUserSid must be NULL. /// /// /// /// /// A flag that specifies the installation context. The function gets the paths of installed components of applications installed in /// the specified installation context. This parameter can be a combination of the following values. /// /// /// /// Context /// Meaning /// /// /// MSIINSTALLCONTEXT_USERMANAGED 1 /// Include applications installed in the per–user–managed installation context. /// /// /// MSIINSTALLCONTEXT_USERUNMANAGED 2 /// Include applications installed in the per–user–unmanaged installation context. /// /// /// MSIINSTALLCONTEXT_MACHINE 4 /// /// Include applications installed in the per-machine installation context. When dwInstallContext is set to /// MSIINSTALLCONTEXT_MACHINE only, the szUserSID parameter must be NULL. /// /// /// /// /// /// /// A string value that receives the path to the component. This parameter can be NULL. If the component is a registry key, /// the registry roots are represented numerically. If this is a registry subkey path, there is a backslash at the end of the Key /// Path. If this is a registry value key path, there is no backslash at the end. For example, a registry path on a 32-bit operating /// system of HKEY_CURRENT_USER\ SOFTWARE\ Microsoft is returned as "01:\SOFTWARE\Microsoft". The registry /// roots returned on 32-bit operating systems are defined as shown in the following table. /// /// /// Note On 64-bit operating systems, a value of 20 is added to the numerical registry roots in this table to distinguish /// them from registry key paths on 32-bit operating systems. For example, a registry key path of HKEY_CURRENT_USER\ /// SOFTWARE\ Microsoft is returned as "21:\SOFTWARE\Microsoft\", if the component path is a registry key on a 64-bit /// operating system. /// /// /// /// Root /// Meaning /// /// /// HKEY_CLASSES_ROOT /// 00 /// /// /// HKEY_CURRENT_USER /// 01 /// /// /// HKEY_LOCAL_MACHINE /// 02 /// /// /// HKEY_USERS /// 03 /// /// /// /// /// Pointer to a location that receives the size of the buffer, in TCHAR, pointed to by the szPathBuf parameter. The value in /// this location should be set to the count of TCHAR in the string including the terminating null character. If the size of /// the buffer is too small, this parameter receives the length of the string value without including the terminating null character /// in the count. /// /// /// The MsiGetComponentPathEx function returns the following values. /// /// /// Value /// Meaning /// /// /// INSTALLSTATE_NOTUSED /// The component being requested is disabled on the computer. /// /// /// INSTALLSTATE_BADCONFIG /// Configuration data is corrupt. /// /// /// INSTALLSTATE_ABSENT /// The component is not installed. /// /// /// INSTALLSTATE_INVALIDARG /// One of the function parameters is invalid. /// /// /// INSTALLSTATE_LOCAL /// The component is installed locally. /// /// /// INSTALLSTATE_SOURCE /// The component is installed to run from source. /// /// /// INSTALLSTATE_SOURCEABSENT /// The component source is inaccessible. /// /// /// INSTALLSTATE_UNKNOWN /// The product code or component ID is unknown. /// /// /// INSTALLSTATE_BROKEN /// The component is corrupt or partially missing in some way and requires repair. /// /// /// /// /// /// The MsiGetComponentPathEx function might return INSTALLSTATE_ABSENT or INSTALL_STATE_UNKNOWN, for the /// following reasons: /// /// /// /// INSTALLSTATE_ABSENT /// /// /// INSTALLSTATE_UNKNOWN /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msigetcomponentpathexa INSTALLSTATE MsiGetComponentPathExA( LPCSTR // szProductCode, LPCSTR szComponentCode, LPCSTR szUserSid, MSIINSTALLCONTEXT dwContext, LPSTR lpOutPathBuffer, LPDWORD // pcchOutPathBuffer ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiGetComponentPathExA")] public static extern INSTALLSTATE MsiGetComponentPathEx([MarshalAs(UnmanagedType.LPTStr)] string szProductCode, [MarshalAs(UnmanagedType.LPTStr)] string szComponentCode, [Optional, MarshalAs(UnmanagedType.LPTStr)] string szUserSid, [Optional] MSIINSTALLCONTEXT dwContext, [Out, Optional, MarshalAs(UnmanagedType.LPTStr)] StringBuilder lpOutPathBuffer, ref uint pcchOutPathBuffer); /// The MsiGetFeatureInfo function returns descriptive information for a feature. /// Handle to the product that owns the feature. This handle is obtained from MsiOpenProduct. /// Feature code for the feature about which information should be returned. /// /// Pointer to a location containing one or more of the following Attribute flags. /// INSTALLFEATUREATTRIBUTE_FAVORLOCAL (1) /// INSTALLFEATUREATTRIBUTE_FAVORSOURCE (2) /// INSTALLFEATUREATTRIBUTE_FOLLOWPARENT (4) /// INSTALLFEATUREATTRIBUTE_FAVORADVERTISE (8) /// INSTALLFEATUREATTRIBUTE_DISALLOWADVERTISE (16) /// INSTALLFEATUREATTRIBUTE_NOUNSUPPORTEDADVERTISE (32) /// /// For more information, see Feature Table. The values that MsiGetFeatureInfo returns are double the values in the /// Attributes column of the Feature Table. /// /// /// /// /// Pointer to a buffer to receive the localized name of the feature, which corresponds to the Title field in the Feature Table. /// /// This parameter is optional and can be null. /// /// /// As input, the size of lpTitleBuf. As output, the number of characters returned in lpTitleBuf. On input, this is the full size of /// the buffer, and includes a space for a terminating null character. If the buffer that is passed in is too small, the count /// returned does not include the terminating null character. /// /// /// Pointer to a buffer to receive the localized description of the feature, which corresponds to the Description field for the /// feature in the Feature table. This parameter is optional and can be null. /// /// /// As input, the size of lpHelpBuf. As output, the number of characters returned in lpHelpBuf. On input, this is the full size of /// the buffer, and includes a space for a terminating null character. If the buffer passed in is too small, the count returned does /// not include the terminating null character. /// /// /// /// /// Return code /// Description /// /// /// ERROR_INVALID_HANDLE /// The product handle is invalid. /// /// /// ERROR_INVALID_PARAMETER /// One of the parameters is invalid. /// /// /// ERROR_MORE_DATA /// A buffer is too small to hold the requested data. /// /// /// ERROR_SUCCESS /// The function returns successfully. /// /// /// ERROR_UNKNOWN_FEATURE /// The feature is not known. /// /// /// /// /// The buffer sizes for the MsiGetFeatureInfo function should include an extra character for the terminating null character. /// If a buffer is too small, the returned string is truncated with null, and the buffer size contains the number of characters in /// the whole string, not including the terminating null character. For more information, see Calling Database Functions From Programs. /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msigetfeatureinfow UINT MsiGetFeatureInfoW( MSIHANDLE hProduct, // LPCWSTR szFeature, LPDWORD lpAttributes, LPWSTR lpTitleBuf, LPDWORD pcchTitleBuf, LPWSTR lpHelpBuf, LPDWORD pcchHelpBuf ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiGetFeatureInfoW")] public static extern Win32Error MsiGetFeatureInfo(MSIHANDLE hProduct, [MarshalAs(UnmanagedType.LPTStr)] string szFeature, out INSTALLFEATUREATTRIBUTE lpAttributes, [Out, Optional, MarshalAs(UnmanagedType.LPTStr)] StringBuilder lpTitleBuf, ref uint pcchTitleBuf, [Out, Optional, MarshalAs(UnmanagedType.LPTStr)] StringBuilder lpHelpBuf, ref uint pcchHelpBuf); /// The MsiGetFeatureUsage function returns the usage metrics for a product feature. /// Specifies the product code for the product that contains the feature. /// Specifies the feature code for the feature for which metrics are to be returned. /// Indicates the number of times the feature has been used. /// /// Specifies the date that the feature was last used. The date is in the MS-DOS date format, as shown in the following table. /// /// /// Bits /// Meaning /// /// /// 0 – 4 /// Day of the month (1-31) /// /// /// 5 – 8 /// Month (1 = January, 2 = February, and so on) /// /// /// 9 – 15 /// Year offset from 1980 (add 1980 to get actual year) /// /// /// /// /// The MsiGetFeatureUsage function returns the following values. /// /// /// Value /// Meaning /// /// /// ERROR_BAD_CONFIGURATION /// The configuration data is corrupt. /// /// /// ERROR_INSTALL_FAILURE /// No usage information is available or the product or feature is invalid. /// /// /// ERROR_SUCCESS /// The function completed successfully. /// /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msigetfeatureusagew UINT MsiGetFeatureUsageW( LPCWSTR szProduct, // LPCWSTR szFeature, LPDWORD pdwUseCount, LPWORD pwDateUsed ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiGetFeatureUsageW")] public static extern Win32Error MsiGetFeatureUsage([MarshalAs(UnmanagedType.LPTStr)] string szProduct, [MarshalAs(UnmanagedType.LPTStr)] string szFeature, out uint pdwUseCount, out ushort pwDateUsed); /// /// /// The MsiGetFileHash function takes the path to a file and returns a 128-bit hash of that file. Authoring tools may use /// MsiGetFileHash to obtain the file hash needed to populate the MsiFileHash table. /// /// /// Windows Installer uses file hashing as a means to detect and eliminate unnecessary file copying. A file hash stored in the /// MsiFileHash table may be compared to a hash of an existing file on the user's computer. /// /// /// Path to file that is to be hashed. /// The value in this column must be 0. This parameter is reserved for future use. /// Pointer to the returned file hash information. /// /// /// /// Value /// Meaning /// /// /// ERROR_SUCCESS /// The function completed successfully. /// /// /// ERROR_FILE_NOT_FOUND /// The file does not exist. /// /// /// ERROR_ACCESS_DENIED /// The file could not be opened to get version information. /// /// /// E_FAIL /// Unexpected error has occurred. /// /// /// /// /// /// The entire 128-bit file hash is returned as four 32-bit fields. The numbering of the four fields is zero-based. The values /// returned by MsiGetFileHash correspond to the four fields of the MSIFILEHASHINFO structure. The first field corresponds to /// the HashPart1 column of the MsiFileHash table, the second field corresponds to the HashPart2 column, the third field corresponds /// to the HashPart3 column, and the fourth field corresponds to the HashPart4 column. /// /// /// The hash information entered into the MsiFileHash table must be obtained by calling MsiGetFileHash or the FileHash /// method. Do not attempt to use other methods to generate the file hash. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msigetfilehasha UINT MsiGetFileHashA( LPCSTR szFilePath, DWORD // dwOptions, PMSIFILEHASHINFO pHash ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiGetFileHashA")] public static extern Win32Error MsiGetFileHash([MarshalAs(UnmanagedType.LPTStr)] string szFilePath, [Optional] uint dwOptions, ref MSIFILEHASHINFO pHash); /// /// /// The MsiGetFileSignatureInformation function takes the path to a file that has been digitally signed and returns the /// file's signer certificate and hash. MsiGetFileSignatureInformation may be called to obtain the signer certificate and /// hash needed to populate the MsiDigitalCertificate, MsiPatchCertificate, and MsiDigitalSignature tables. /// /// /// Windows Installer 3.0 and later: Beginning with Windows Installer 3.0, the Windows Installer can verify the digital /// signatures of patches (.msp files) by using the MsiPatchCertificate and MsiDigitalCertificate tables. For more information see /// Guidelines for Authoring Secure Installations and User Account Control (UAC) Patching. /// /// /// Windows Installer 2.0: Digital signatures of patches is not supported. Windows Installer 2.0 uses digital signatures as a /// means to detect corrupted resources, and can only verify the digital signatures of external cabinets, and only by the use of the /// MsiDigitalSignature and MsiDigitalCertificate tables. /// /// /// /// Pointer to a null-terminated string specifying the full path to the file that contains the digital signature. /// /// /// Special error case flags. /// /// /// Flag /// Meaning /// /// /// MSI_INVALID_HASH_IS_FATAL 0x1 /// /// Without this flag set, and when requesting only the certificate context, an invalid hash in the digital signature does not cause /// MsiGetFileSignatureInformation to return a fatal error. To return a fatal error for an invalid hash, set the /// MSI_INVALID_HASH_IS_FATAL flag. /// /// /// /// /// Returned signer certificate context /// Returned hash buffer. This parameter can be NULL if the hash data is not being requested. /// /// Pointer to a variable that specifies the size, in bytes, of the buffer pointed to by the pbHashData parameter. This parameter /// cannot be NULL if pbHashData is non- NULL. If ERROR_MORE_DATA is returned, pbHashData gives the size of the buffer /// required to hold the hash data. If ERROR_SUCCESS is returned, it gives the number of bytes written to the hash buffer. The /// pcbHashData parameter is ignored if pbHashData is NULL. /// /// /// /// /// Value /// Meaning /// /// /// ERROR_SUCCESS/S_OK /// Successful completion. /// /// /// ERROR_INVALID_PARAMETER /// Invalid parameter was specified. /// /// /// ERROR_FUNCTION_FAILED /// /// WinVerifyTrust is not available on the system. MsiGetFileSignatureInformation requires the presence of the Wintrust.dll file on /// the system. /// /// /// /// ERROR_MORE_DATA /// /// A buffer is too small to hold the requested data. If ERROR_MORE_DATA is returned, pcbHashData gives the size of the buffer /// required to hold the hash data. /// /// /// /// TRUST_E_NOSIGNATURE /// File is not signed /// /// /// TRUST_E_BAD_DIGEST /// The file's current hash is invalid according to the hash stored in the file's digital signature. /// /// /// CERT_E_REVOKED /// The file's signer certificate has been revoked. The file's digital signature is compromised. /// /// /// TRUST_E_SUBJECT_NOT_TRUSTED /// /// The subject failed the specified verification action. Most trust providers return a more detailed error code that describes the /// reason for the failure. /// /// /// /// TRUST_E_PROVIDER_UNKNOWN /// The trust provider is not recognized on this system. /// /// /// TRUST_E_ACTION_UNKNOWN /// The trust provider does not support the specified action. /// /// /// TRUST_E_SUBJECT_FORM_UNKNOWN /// The trust provider does not support the form specified for the subject. /// /// /// /// MsiGetFileSignatureInformation also returns all the Win32 error values mapped to their equivalent HRESULT data /// type by HRESULT_FROM_WIN32. /// /// /// /// /// When requesting only the certificate context, an invalid hash in the digital signature does not cause /// MsiGetFileSignatureInformation to return a fatal error. To return a fatal error for an invalid hash, set the /// MSI_INVALID_HASH_IS_FATAL flag in the dwFlags parameter. /// /// /// The certificate context and hash information is extracted from the file by a call to WinVerifyTrust. The ppcCertContext /// parameter is a duplicate of the signer certificate context from the signature. It is the responsibility of the caller to call /// CertFreeCertificateContext to free the certificate context when finished. /// /// Note that MsiGetFileSignatureInformation requires the presence of the Wintrust.dll file on the system. /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msigetfilesignatureinformationw HRESULT // MsiGetFileSignatureInformationW( LPCWSTR szSignedObjectPath, DWORD dwFlags, PCCERT_CONTEXT *ppcCertContext, LPBYTE pbHashData, // LPDWORD pcbHashData ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiGetFileSignatureInformationW")] public static extern HRESULT MsiGetFileSignatureInformation([MarshalAs(UnmanagedType.LPTStr)] string szSignedObjectPath, MSISIGINFO dwFlags, out SafePCCERT_CONTEXT ppcCertContext, [Out, Optional] IntPtr pbHashData, ref uint pcbHashData); /// /// The MsiGetFileVersion returns the version string and language string in the format that the installer expects to find /// them in the database. If you want only version information, set lpLangBuf and pcchLangBuf to 0 (zero). If you just want language /// information, set lpVersionBuf and pcchVersionBuf to 0 (zero). /// /// Specifies the path to the file. /// /// Returns the file version. /// Set to 0 for language information only. /// /// /// In and out buffer count as the number of TCHAR. /// /// Set to 0 (zero) for language information only. On input, this is the full size of the buffer, including a space for a /// terminating null character. If the buffer passed in is too small, the count returned does not include the terminating null character. /// /// /// /// Returns the file language. /// Set to 0 (zero) for version information only. /// /// /// In and out buffer count as the number of TCHAR. /// /// Set to 0 (zero) for version information only. On input, this is the full size of the buffer, including a space for a terminating /// null character. If the buffer passed in is too small, the count returned does not include the terminating null character. /// /// /// /// /// /// Value /// Meaning /// /// /// ERROR_SUCCESS /// Successful completion. /// /// /// ERROR_FILE_NOT_FOUND /// File does not exist. /// /// /// ERROR_ACCESS_DENIED /// File cannot be opened to get version information. /// /// /// ERROR_FILE_INVALID /// File does not contain version information. /// /// /// ERROR_INVALID_DATA /// The version information is invalid. /// /// /// E_FAIL /// Unexpected error. /// /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msigetfileversiona UINT MsiGetFileVersionA( LPCSTR szFilePath, // LPSTR lpVersionBuf, LPDWORD pcchVersionBuf, LPSTR lpLangBuf, LPDWORD pcchLangBuf ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiGetFileVersionA")] public static extern Win32Error MsiGetFileVersion([MarshalAs(UnmanagedType.LPTStr)] string szFilePath, [Out, Optional, MarshalAs(UnmanagedType.LPTStr)] StringBuilder lpVersionBuf, ref uint pcchVersionBuf, [Out, Optional, MarshalAs(UnmanagedType.LPTStr)] StringBuilder lpLangBuf, ref uint pcchLangBuf); /// /// The MsiGetFileVersion returns the version string and language string in the format that the installer expects to find /// them in the database. If you want only version information, set lpLangBuf and pcchLangBuf to 0 (zero). If you just want language /// information, set lpVersionBuf and pcchVersionBuf to 0 (zero). /// /// Specifies the path to the file. /// /// Returns the file version. /// Set to 0 for language information only. /// /// /// In and out buffer count as the number of TCHAR. /// /// Set to 0 (zero) for language information only. On input, this is the full size of the buffer, including a space for a /// terminating null character. If the buffer passed in is too small, the count returned does not include the terminating null character. /// /// /// /// Returns the file language. /// Set to 0 (zero) for version information only. /// /// /// In and out buffer count as the number of TCHAR. /// /// Set to 0 (zero) for version information only. On input, this is the full size of the buffer, including a space for a terminating /// null character. If the buffer passed in is too small, the count returned does not include the terminating null character. /// /// /// /// /// /// Value /// Meaning /// /// /// ERROR_SUCCESS /// Successful completion. /// /// /// ERROR_FILE_NOT_FOUND /// File does not exist. /// /// /// ERROR_ACCESS_DENIED /// File cannot be opened to get version information. /// /// /// ERROR_FILE_INVALID /// File does not contain version information. /// /// /// ERROR_INVALID_DATA /// The version information is invalid. /// /// /// E_FAIL /// Unexpected error. /// /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msigetfileversiona UINT MsiGetFileVersionA( LPCSTR szFilePath, // LPSTR lpVersionBuf, LPDWORD pcchVersionBuf, LPSTR lpLangBuf, LPDWORD pcchLangBuf ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiGetFileVersionA")] public static extern Win32Error MsiGetFileVersion([MarshalAs(UnmanagedType.LPTStr)] string szFilePath, [Out, Optional, MarshalAs(UnmanagedType.LPTStr)] StringBuilder lpVersionBuf, [In, Optional] IntPtr pcchVersionBuf, [Out, Optional, MarshalAs(UnmanagedType.LPTStr)] StringBuilder lpLangBuf, [In, Optional] IntPtr pcchLangBuf); /// /// The MsiGetPatchFileList function is provided a list of .msp files, delimited by semicolons, and retrieves the list of /// files that can be updated by the patches. /// /// /// A null-terminated string value containing the ProductCode (GUID) of the product which is the target of the patches. This /// parameter cannot be NULL. /// /// /// A null-terminated string value that contains the list of Windows Installer patches (.msp files). Each patch can be specified by /// the full path to the patch package. The patches in the list are delimited by semicolons. At least one patch must be specified. /// /// /// A pointer to a location that receives the number of files that will be updated on this system by this list of patches specified /// by szPatchList. This parameter is required. /// /// /// A pointer to a location that receives a pointer to an array of records. The first field (0-index) of each record contains the /// full file path of a file that can be updated when the list of patches in szPatchList are applied on this computer. This /// parameter is required. /// /// /// The MsiGetPatchFileList function returns the following values. /// /// /// Value /// Meaning /// /// /// ERROR_SUCCESS /// The function completed successfully. /// /// /// ERROR_INVALID_PARAMETER /// An invalid parameter was passed to the function. /// /// /// ERROR_FUNCTION_FAILED /// The function failed. /// /// /// /// /// /// For example, szPatchList could have the value: "c:\sus\download\cache\Office\sp1.msp; c:\sus\download\cache\Office\QFE1.msp; c:\sus\download\cache\Office\QFEn.msp". /// /// /// This function runs in the context of the caller. The product code is searched in the order of user-unmanaged context, /// user-managed context, and machine context. /// /// You must close all MSIHANDLE objects that are returned by this function by calling the MsiCloseHandle function. /// If the function fails, you can obtain extended error information by using the MsiGetLastErrorRecord function. /// For more information about using the MsiGetPatchFileList function see Listing the Files that can be Updated. /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msigetpatchfilelista UINT MsiGetPatchFileListA( LPCSTR // szProductCode, LPCSTR szPatchPackages, LPDWORD pcFiles, MSIHANDLE **pphFileRecords ); [DllImport(Lib_Msi, SetLastError = true, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiGetPatchFileListA")] public static extern Win32Error MsiGetPatchFileList([MarshalAs(UnmanagedType.LPTStr)] string szProductCode, [MarshalAs(UnmanagedType.LPTStr)] string szPatchPackages, out uint pcFiles, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] out MSIHANDLE[] pphFileRecords); /// The MsiGetPatchInfo function returns information about a patch. /// Specifies the patch code for the patch package. /// /// Specifies the attribute to be retrieved. /// /// /// Attribute /// Meaning /// /// /// INSTALLPROPERTY_LOCALPACKAGE /// Local cached package. /// /// /// /// Pointer to a buffer that receives the property value. This parameter can be null. /// /// /// Pointer to a variable that specifies the size, in characters, of the buffer pointed to by the lpValueBuf parameter. On input, /// this is the full size of the buffer, including a space for a terminating null character. If the buffer passed in is too small, /// the count returned does not include the terminating null character. /// /// If lpValueBuf is null, pcchValueBuf can be null. /// /// /// The MsiGetPatchInfo function returns the following values. /// /// /// Value /// Meaning /// /// /// ERROR_BAD_CONFIGURATION /// The configuration data is corrupt. /// /// /// ERROR_INVALID_PARAMETER /// An invalid parameter was passed to the function. /// /// /// ERROR_MORE_DATA /// A buffer is too small to hold the requested data. /// /// /// ERROR_SUCCESS /// The function completed successfully. /// /// /// ERROR_UNKNOWN_PRODUCT /// The patch package is not installed. /// /// /// ERROR_UNKNOWN_PROPERTY /// The property is unrecognized. /// /// /// /// /// /// When the MsiGetPatchInfo function returns, the pcchValueBuf parameter contains the length of the class string stored in /// the buffer. The count returned does not include the terminating null character. /// /// /// If the buffer is too small to hold the requested data, MsiGetPatchInfo returns ERROR_MORE_DATA, and pcchValueBuf contains /// the number of characters copied to lpValueBuf, without counting the null character. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msigetpatchinfoa UINT MsiGetPatchInfoA( LPCSTR szPatch, LPCSTR // szAttribute, LPSTR lpValueBuf, LPDWORD pcchValueBuf ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiGetPatchInfoA")] public static extern Win32Error MsiGetPatchInfo([MarshalAs(UnmanagedType.LPTStr)] string szPatch, [MarshalAs(UnmanagedType.LPTStr)] string szAttribute, [Out, Optional, MarshalAs(UnmanagedType.LPTStr)] StringBuilder lpValueBuf, ref uint pcchValueBuf); /// /// The MsiGetPatchInfoEx function queries for information about the application of a patch to a specified instance of a product. /// /// A null-terminated string that contains the GUID of the patch. This parameter cannot be NULL. /// /// A null-terminated string that contains the ProductCode GUID of the product instance. This parameter cannot be NULL. /// /// /// /// A null-terminated string that specifies the security identifier (SID) under which the instance of the patch being queried /// exists. Using a NULL value specifies the current user. /// /// /// /// SID /// Meaning /// /// /// NULL /// Specifies the user that is logged on. /// /// /// User SID /// /// Specifies the enumeration for a specific user ID in the system. The following example identifies a possible user SID: "S-1-3-64-2415071341-1358098788-3127455600-2561". /// /// /// /// /// Note The special SID string "S-1-5-18" (system) cannot be used to enumerate products installed as per-machine. If /// dwContext is MSIINSTALLCONTEXT_MACHINE, szUserSid must be NULL. /// /// /// /// /// Restricts the enumeration to a per-user-unmanaged, per-user-managed, or per-machine context. This parameter can be any one of /// the following values. /// /// /// /// Context /// Meaning /// /// /// MSIINSTALLCONTEXT_USERMANAGED 1 /// Query that is extended to all per–user-managed installations for the users that szUserSid specifies. /// /// /// MSIINSTALLCONTEXT_USERUNMANAGED 2 /// Query that is extended to all per–user-unmanaged installations for the users that szUserSid specifies. /// /// /// MSIINSTALLCONTEXT_MACHINE 4 /// Query that is extended to all per-machine installations. /// /// /// /// /// A null-terminated string that specifies the property value to retrieve. The szProperty parameter can be one of the following: /// /// /// Name /// Meaning /// /// /// INSTALLPROPERTY_LOCALPACKAGE "LocalPackage" /// Gets the cached patch file that the product uses. /// /// /// INSTALLPROPERTY_TRANSFORMS "Transforms" /// /// Gets the set of patch transforms that the last patch installation applied to the product. This value may not be available for /// per-user, non-managed applications if the user is not logged on. /// /// /// /// INSTALLPROPERTY_INSTALLDATE "InstallDate" /// /// Gets the last time this product received service. The value of this property is replaced each time a patch is applied or removed /// from the product or the /v Command-Line Option is used to repair the product. If the product has received no repairs or patches /// this property contains the time this product was installed on this computer. /// /// /// /// INSTALLPROPERTY_UNINSTALLABLE "Uninstallable" /// /// Returns "1" if the patch is marked as possible to uninstall from the product. In this case, the installer can still block the /// uninstallation if this patch is required by another patch that cannot be uninstalled. /// /// /// /// INSTALLPROPERTY_PATCHSTATE "State" /// /// Returns "1" if this patch is currently applied to the product. Returns "2" if this patch is superseded by another patch. Returns /// "4" if this patch is obsolete. These values correspond to the constants the dwFilter parameter of MsiEnumPatchesEx uses. /// /// /// /// INSTALLPROPERTY_DISPLAYNAME "DisplayName" /// /// Get the registered display name for the patch. For patches that do not include the DisplayName property in the MsiPatchMetadata /// table, the returned display name is an empty string (""). /// /// /// /// INSTALLPROPERTY_MOREINFOURL "MoreInfoURL" /// /// Get the registered support information URL for the patch. For patches that do not include the MoreInfoURL property in the /// MsiPatchMetadata table, the returned support information URL is an empty string (""). /// /// /// /// /// /// /// This parameter is a pointer to a buffer that receives the property value. This buffer should be large enough to contain the /// information. If the buffer is too small, the function returns ERROR_MORE_DATA and sets *pcchValue to the number of /// TCHAR in the property value, not including the terminating NULL character. /// /// /// If lpValue is set to NULL and pcchValue is set to a valid pointer, the function returns ERROR_SUCCESS and sets /// *pcchValue to the number of TCHAR in the value, not including the terminating NULL character. The function can /// then be called again to retrieve the value, with lpValue buffer large enough to contain *pcchValue + 1 characters. /// /// /// If lpValue and pcchValue are both set to NULL, the function returns ERROR_SUCCESS if the value exists, without /// retrieving the value. /// /// /// /// /// When calling the function, this parameter should be a pointer to a variable that specifies the number of TCHAR in the /// lpValue buffer. When the function returns, this parameter is set to the size of the requested value whether or not the function /// copies the value into the specified buffer. The size is returned as the number of TCHAR in the requested value, not /// including the terminating null character. /// /// This parameter can be set to NULL only if lpValue is also NULL. Otherwise, the function returns ERROR_INVALID_PARAMETER. /// /// /// The MsiGetPatchInfoEx function returns the following values. /// /// /// Return code /// Description /// /// /// ERROR_ACCESS_DENIED /// The function fails trying to access a resource with insufficient privileges. /// /// /// ERROR_BAD_CONFIGURATION /// The configuration data is corrupt. /// /// /// ERROR_FUNCTION_FAILED /// The function fails and the error is not identified in other error codes. /// /// /// ERROR_INVALID_PARAMETER /// An invalid parameter is passed to the function. /// /// /// ERROR_MORE_DATA /// The value does not fit in the provided buffer. /// /// /// ERROR_SUCCESS /// The patch is enumerated successfully. /// /// /// ERROR_UNKNOWN_PRODUCT /// The product that szProduct specifies is not installed on the computer. /// /// /// ERROR_UNKNOWN_PROPERTY /// The property is unrecognized. /// /// /// ERROR_UNKNOWN_PATCH /// The patch is unrecognized. /// /// /// /// /// Windows Installer 2.0: Not supported. This function is available beginning with Windows Installer version 3.0. /// /// A user may query patch data for any product instance that is visible. The administrator group can query patch data for any /// product instance and any user on the computer. Not all values are guaranteed to be available for per-user, non-managed /// applications if the user is not logged on. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msigetpatchinfoexa UINT MsiGetPatchInfoExA( LPCSTR szPatchCode, // LPCSTR szProductCode, LPCSTR szUserSid, MSIINSTALLCONTEXT dwContext, LPCSTR szProperty, LPSTR lpValue, LPDWORD pcchValue ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiGetPatchInfoExA")] public static extern Win32Error MsiGetPatchInfoEx([MarshalAs(UnmanagedType.LPTStr)] string szPatchCode, [MarshalAs(UnmanagedType.LPTStr)] string szProductCode, [Optional, MarshalAs(UnmanagedType.LPTStr)] string szUserSid, MSIINSTALLCONTEXT dwContext, [MarshalAs(UnmanagedType.LPTStr)] string szProperty, [Out, Optional, MarshalAs(UnmanagedType.LPTStr)] StringBuilder lpValue, ref uint pcchValue); /// /// The MsiGetProductCode function returns the product code of an application by using the component code of an installed or /// advertised component of the application. During initialization, an application must determine under which product code it has /// been installed or advertised. /// /// /// This parameter specifies the component code of a component that has been installed by the application. This will be typically /// the component code of the component containing the executable file of the application. /// /// /// Pointer to a buffer that receives the product code. This buffer must be 39 characters long. The first 38 characters are for the /// GUID, and the last character is for the terminating null character. /// /// /// /// /// Value /// Meaning /// /// /// ERROR_BAD_CONFIGURATION /// The configuration data is corrupt. /// /// /// ERROR_INSTALL_FAILURE /// The product code could not be determined. /// /// /// ERROR_INVALID_PARAMETER /// An invalid parameter was passed to the function. /// /// /// ERROR_SUCCESS /// The function completed successfully. /// /// /// ERROR_UNKNOWN_COMPONENT /// The specified component is unknown. /// /// /// /// /// During initialization, an application must determine the product code under which it was installed. An application can be part /// of different products in different installations. For example, an application can be part of a suite of applications, or it can /// be installed by itself. /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msigetproductcodea UINT MsiGetProductCodeA( LPCSTR szComponent, // LPSTR lpBuf39 ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiGetProductCodeA")] public static extern Win32Error MsiGetProductCode([MarshalAs(UnmanagedType.LPTStr)] string szComponent, [Out, MarshalAs(UnmanagedType.LPTStr)] StringBuilder lpBuf39); /// The MsiGetProductInfo function returns product information for published and installed products. /// Specifies the product code for the product. /// /// Specifies the property to be retrieved. /// /// The Required Properties are guaranteed to be available, but other properties are available only if that property is set. For /// more information, see Properties. The properties in the following list can be retrieved only from applications that are installed. /// /// /// /// Property /// Meaning /// /// /// INSTALLPROPERTY_HELPLINK /// Support link. For more information, see the ARPHELPLINK property. /// /// /// INSTALLPROPERTY_HELPTELEPHONE /// Support telephone. For more information, see the ARPHELPTELEPHONE property. /// /// /// INSTALLPROPERTY_INSTALLDATE /// /// The last time this product received service. The value of this property is replaced each time a patch is applied or removed from /// the product or the /v Command-Line Option is used to repair the product. If the product has received no repairs or patches this /// property contains the time this product was installed on this computer. /// /// /// /// INSTALLPROPERTY_INSTALLEDLANGUAGE /// Installed language. Windows Installer 4.5 and earlier: Not supported. /// /// /// INSTALLPROPERTY_INSTALLEDPRODUCTNAME /// Installed product name. For more information, see the ProductName property. /// /// /// INSTALLPROPERTY_INSTALLLOCATION /// Installation location. For more information, see the ARPINSTALLLOCATION property. /// /// /// INSTALLPROPERTY_INSTALLSOURCE /// Installation source. For more information, see the SourceDir property. /// /// /// INSTALLPROPERTY_LOCALPACKAGE /// Local cached package. /// /// /// INSTALLPROPERTY_PUBLISHER /// Publisher. For more information, see the Manufacturer property. /// /// /// INSTALLPROPERTY_URLINFOABOUT /// URL information. For more information, see the ARPURLINFOABOUT property. /// /// /// INSTALLPROPERTY_URLUPDATEINFO /// URL update information. For more information, see the ARPURLUPDATEINFO property. /// /// /// INSTALLPROPERTY_VERSIONMINOR /// Minor product version derived from the ProductVersion property. /// /// /// INSTALLPROPERTY_VERSIONMAJOR /// Major product version derived from the ProductVersion property. /// /// /// INSTALLPROPERTY_VERSIONSTRING /// Product version. For more information, see the ProductVersion property. /// /// /// /// To retrieve the product ID, registered owner, or registered company from applications that are installed, set szProperty to one /// of the following text string values. /// /// /// /// Value /// Description /// /// /// ProductID /// The product identifier for the product. For more information, see the ProductID property. /// /// /// RegCompany /// The company registered to use this product. /// /// /// RegOwner /// The owner registered to use this product. /// /// /// /// To retrieve the instance type of the product, set szProperty to the following value. This property is available for advertised /// or installed products. /// /// /// /// Value /// Description /// /// /// InstanceType /// /// A missing value or a value of 0 (zero) indicates a normal product installation. A value of 1 (one) indicates a product installed /// using a multiple instance transform and the MSINEWINSTANCE property. Available with the installer running Windows Server 2003 or /// Windows XP with SP1. For more information see, Installing Multiple Instances of Products and Patches. /// /// /// /// The advertised properties in the following list can be retrieved from applications that are advertised or installed. /// /// /// Property /// Description /// /// /// INSTALLPROPERTY_TRANSFORMS /// Transforms. /// /// /// INSTALLPROPERTY_LANGUAGE /// Product language. /// /// /// INSTALLPROPERTY_PRODUCTNAME /// Human readable product name. For more information, see the ProductName property. /// /// /// INSTALLPROPERTY_ASSIGNMENTTYPE /// /// Equals 0 (zero) if the product is advertised or installed per-user. Equals 1 (one) if the product is advertised or installed /// per-machine for all users. /// /// /// /// INSTALLPROPERTY_PACKAGECODE /// Identifier of the package this product was installed from. For more information, see Package Codes. /// /// /// INSTALLPROPERTY_VERSION /// Product version derived from the ProductVersion property. /// /// /// INSTALLPROPERTY_PRODUCTICON /// Primary icon for the package. For more information, see the ARPPRODUCTICON property. /// /// /// INSTALLPROPERTY_PACKAGENAME /// Name of the original installation package. /// /// /// INSTALLPROPERTY_AUTHORIZED_LUA_APP /// /// A value of one (1) indicates a product that can be serviced by non-administrators using User Account Control (UAC) Patching. A /// missing value or a value of 0 (zero) indicates that least-privilege patching is not enabled. Available in Windows Installer 3.0 /// or later. /// /// /// /// /// Pointer to a buffer that receives the property value. This parameter can be null. /// /// /// Pointer to a variable that specifies the size, in characters, of the buffer pointed to by the lpValueBuf parameter. On input, /// this is the full size of the buffer, including a space for a terminating null character. If the buffer passed in is too small, /// the count returned does not include the terminating null character. /// /// /// If lpValueBuf is null, pcchValueBuf can be null. In this case, the function checks that the property is registered correctly /// with the product. /// /// /// /// /// /// Value /// Meaning /// /// /// ERROR_BAD_CONFIGURATION /// The configuration data is corrupt. /// /// /// ERROR_INVALID_PARAMETER /// An invalid parameter was passed to the function. /// /// /// ERROR_MORE_DATA /// A buffer is too small to hold the requested data. /// /// /// ERROR_SUCCESS /// The function completed successfully. /// /// /// ERROR_UNKNOWN_PRODUCT /// The product is unadvertised or uninstalled. /// /// /// ERROR_UNKNOWN_PROPERTY /// The property is unrecognized. /// /// /// /// /// /// When the MsiGetProductInfo function returns, the pcchValueBuf parameter contains the length of the string stored in the /// buffer. The count returned does not include the terminating null character. If the buffer is not large enough, /// MsiGetProductInfo returns ERROR_MORE_DATA and pcchValueBuf contains the size of the string, in characters, without /// counting the null character. /// /// /// MsiGetProductInfo(INSTALLPROPERTY_LOCALPACKAGE) does not necessarily return a path to the cached package. The cached /// package is for internal use only. Maintenance mode installations should be invoked through the MsiConfigureFeature, /// MsiConfigureProduct, or MsiConfigureProductEx functions. /// /// /// If you attempt to use MsiGetProductInfo to query an advertised product for a property that is only available to installed /// products, the function returns ERROR_UNKNOWN_PROPERTY. For example, if the application is advertised and not installed, a query /// for the INSTALLPROPERTY_INSTALLLOCATION property returns an error of ERROR_UNKNOWN_PROPERTY. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msigetproductinfoa UINT MsiGetProductInfoA( LPCSTR szProduct, // LPCSTR szAttribute, LPSTR lpValueBuf, LPDWORD pcchValueBuf ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiGetProductInfoA")] public static extern Win32Error MsiGetProductInfo([MarshalAs(UnmanagedType.LPTStr)] string szProduct, [MarshalAs(UnmanagedType.LPTStr)] string szAttribute, [Out, Optional, MarshalAs(UnmanagedType.LPTStr)] StringBuilder lpValueBuf, ref uint pcchValueBuf); /// /// /// The MsiGetProductInfoEx function returns product information for advertised and installed products. This function can /// retrieve information /// /// about an instance of a product that is installed under a user account other than the current user. /// /// The calling process must have administrative privileges for a user who is different from the current user. The /// MsiGetProductInfoEx function cannot query an instance of a product that is advertised under a per-user-unmanaged context /// for a user account other than the current user. /// /// This function is an extension of the MsiGetProductInfo function. /// /// The ProductCode GUID of the product instance that is being queried. /// /// /// The security identifier (SID) of the account under which the instance of the product that is being queried exists. A NULL /// specifies the current user SID. /// /// /// /// SID /// Meaning /// /// /// NULL /// The currently logged-on user. /// /// /// User SID /// The enumeration for a specific user in the system. An example of user SID is "S-1-3-64-2415071341-1358098788-3127455600-2561". /// /// /// /// Note The special SID string "S-1-5-18" (system) cannot be used to enumerate products installed as per-machine. If /// dwContext is "MSIINSTALLCONTEXT_MACHINE", szUserSid must be NULL. /// /// /// /// The installation context of the product instance that is being queried. /// /// /// Name /// Meaning /// /// /// MSIINSTALLCONTEXT_USERMANAGED /// Retrieves the product property for the per–user–managed instance of the product. /// /// /// MSIINSTALLCONTEXT_USERUNMANAGED /// Retrieves the product property for the per–user–unmanaged instance of the product. /// /// /// MSIINSTALLCONTEXT_MACHINE /// Retrieves the product property for the per-machine instance of the product. /// /// /// /// /// Property being queried. /// /// The property to be retrieved. The properties in the following table can only be retrieved from applications that are already /// installed. All required properties are guaranteed to be available, but other properties are available only if the property is /// set. For more information, see Required Properties and Properties. /// /// /// /// Property /// Meaning /// /// /// INSTALLPROPERTY_PRODUCTSTATE /// The state of the product returned in string form as "1" for advertised and "5" for installed. /// /// /// INSTALLPROPERTY_HELPLINK /// The support link. For more information, see the ARPHELPLINK property. /// /// /// INSTALLPROPERTY_HELPTELEPHONE /// The support telephone. For more information, see the ARPHELPTELEPHONE property. /// /// /// INSTALLPROPERTY_INSTALLDATE /// /// The last time this product received service. The value of this property is replaced each time a patch is applied or removed from /// the product or the /v Command-Line Option is used to repair the product. If the product has received no repairs or patches this /// property contains the time this product was installed on this computer. /// /// /// /// INSTALLPROPERTY_INSTALLEDLANGUAGE /// Installed language. Windows Installer 4.5 and earlier: Not supported. /// /// /// INSTALLPROPERTY_INSTALLEDPRODUCTNAME /// The installed product name. For more information, see the ProductName property. /// /// /// INSTALLPROPERTY_INSTALLLOCATION /// The installation location. For more information, see the ARPINSTALLLOCATION property. /// /// /// INSTALLPROPERTY_INSTALLSOURCE /// The installation source. For more information, see the SourceDir property. /// /// /// INSTALLPROPERTY_LOCALPACKAGE /// The local cached package. /// /// /// INSTALLPROPERTY_PUBLISHER /// The publisher. For more information, see the Manufacturer property. /// /// /// INSTALLPROPERTY_URLINFOABOUT /// URL information. For more information, see the ARPURLINFOABOUT property. /// /// /// INSTALLPROPERTY_URLUPDATEINFO /// The URL update information. For more information, see the ARPURLUPDATEINFO property. /// /// /// INSTALLPROPERTY_VERSIONMINOR /// The minor product version that is derived from the ProductVersion property. /// /// /// INSTALLPROPERTY_VERSIONMAJOR /// The major product version that is derived from the ProductVersion property. /// /// /// INSTALLPROPERTY_VERSIONSTRING /// The product version. For more information, see the ProductVersion property. /// /// /// /// To retrieve the product ID, registered owner, or registered company from applications that are installed, set szProperty to one /// of the following text string values. /// /// /// /// Value /// Description /// /// /// ProductID /// The product identifier. For more information, see the ProductID property. /// /// /// RegCompany /// The company that is registered to use the product. /// /// /// RegOwner /// The owner who is registered to use the product. /// /// /// /// To retrieve the instance type of the product, set szProperty to the following value. This property is available for advertised /// or installed products. /// /// /// /// Value /// Description /// /// /// InstanceType /// /// A missing value or a value of 0 (zero) indicates a normal product installation. A value of one (1) indicates a product installed /// using a multiple instance transform and the MSINEWINSTANCE property. For more information, see Installing Multiple Instances of /// Products and Patches. /// /// /// /// /// The properties in the following table can be retrieved from applications that are advertised or installed. These properties /// cannot be retrieved for product instances that are installed under a per-user-unmanaged context for user accounts other than /// current user account. /// /// /// /// Property /// Description /// /// /// INSTALLPROPERTY_TRANSFORMS /// Transforms. /// /// /// INSTALLPROPERTY_LANGUAGE /// Product language. /// /// /// INSTALLPROPERTY_PRODUCTNAME /// Human readable product name. For more information, see the ProductName property. /// /// /// INSTALLPROPERTY_ASSIGNMENTTYPE /// /// Equals 0 (zero) if the product is advertised or installed per-user. Equals one (1) if the product is advertised or installed /// per-computer for all users. /// /// /// /// INSTALLPROPERTY_PACKAGECODE /// Identifier of the package that a product is installed from. For more information, see the Package Codes property. /// /// /// INSTALLPROPERTY_VERSION /// Product version derived from the ProductVersion property. /// /// /// INSTALLPROPERTY_PRODUCTICON /// Primary icon for the package. For more information, see the ARPPRODUCTICON property. /// /// /// INSTALLPROPERTY_PACKAGENAME /// Name of the original installation package. /// /// /// INSTALLPROPERTY_AUTHORIZED_LUA_APP /// /// A value of one (1) indicates a product that can be serviced by non-administrators using User Account Control (UAC) Patching. A /// missing value or a value of 0 (zero) indicates that least-privilege patching is not enabled. Available in Windows Installer 3.0 /// or later. /// /// /// /// /// /// /// A pointer to a buffer that receives the property value. This buffer should be large enough to contain the information. If the /// buffer is too small, the function returns ERROR_MORE_DATA and sets *pcchValue to the number of TCHAR in the value, /// not including the terminating NULL character. /// /// /// If lpValue is set to NULL and pcchValue is set to a valid pointer, the function returns ERROR_SUCCESS and sets /// *pcchValue to the number of TCHAR in the value, not including the terminating NULL character. The function can then be /// called again to retrieve the value, with lpValue buffer large enough to contain *pcchValue + 1 characters. /// /// /// If lpValue and pcchValue are both set to NULL, the function returns ERROR_SUCCESS if the value exists, without /// retrieving the value. /// /// /// /// /// A pointer to a variable that specifies the number of TCHAR in the lpValue buffer. When the function returns, this /// parameter is set to the size of the requested value whether or not the function copies the value into the specified buffer. The /// size is returned as the number of TCHAR in the requested value, not including the terminating null character. /// /// This parameter can be set to NULL only if lpValue is also NULL. Otherwise, the function returns ERROR_INVALID_PARAMETER. /// /// /// The MsiGetProductInfoEx function returns the following values. /// /// /// Return code /// Description /// /// /// ERROR_ACCESS_DENIED /// /// The calling process must have administrative privileges to get information for a product installed for a user other than the /// current user. /// /// /// /// ERROR_BAD_CONFIGURATION /// The configuration data is corrupt. /// /// /// ERROR_INVALID_PARAMETER /// An invalid parameter is passed to the function. /// /// /// ERROR_MORE_DATA /// A buffer is too small to hold the requested data. /// /// /// ERROR_SUCCESS /// The function completed successfully. /// /// /// ERROR_UNKNOWN_PRODUCT /// The product is unadvertised or uninstalled. /// /// /// ERROR_UNKNOWN_PROPERTY /// The property is unrecognized. /// /// /// ERROR_FUNCTION_FAILED /// An unexpected internal failure. /// /// /// /// /// /// When the MsiGetProductInfoEx function returns, the pcchValue parameter contains the length of the string that is stored /// in the buffer. The count returned does not include the terminating null character. If the buffer is not big enough, /// MsiGetProductInfoEx returns ERROR_MORE_DATA, and the pcchValue parameter contains the size of the string, in /// TCHAR, without counting the null character. /// /// /// The MsiGetProductInfoEx function ( INSTALLPROPERTY_LOCALPACKAGE) returns a path to the cached package. The cached /// package is for internal use only. Maintenance mode installations must be invoked through the MsiConfigureFeature, /// MsiConfigureProduct, or MsiConfigureProductEx functions. /// /// /// The MsiGetProductInfo function returns ERROR_UNKNOWN_PROPERTY if the application being queried is advertised and not /// installed. For example, if the application is advertised and not installed, a query for INSTALLPROPERTY_INSTALLLOCATION /// returns an error of ERROR_UNKNOWN_PROPERTY. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msigetproductinfoexa UINT MsiGetProductInfoExA( LPCSTR // szProductCode, LPCSTR szUserSid, MSIINSTALLCONTEXT dwContext, LPCSTR szProperty, LPSTR szValue, LPDWORD pcchValue ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiGetProductInfoExA")] public static extern Win32Error MsiGetProductInfoEx([MarshalAs(UnmanagedType.LPTStr)] string szProductCode, [Optional, MarshalAs(UnmanagedType.LPTStr)] string szUserSid, MSIINSTALLCONTEXT dwContext, [MarshalAs(UnmanagedType.LPTStr)] string szProperty, [Out, MarshalAs(UnmanagedType.LPTStr)] StringBuilder szValue, ref uint pcchValue); /// The MsiGetProductInfoFromScript function returns product information for a Windows Installer script file. /// /// A null-terminated string specifying the full path to the script file. The script file is the advertise script that was created /// by calling MsiAdvertiseProduct or MsiAdvertiseProductEx. /// /// /// Points to a buffer that receives the product code. The buffer must be 39 characters long. The first 38 characters are for the /// product code GUID, and the last character is for the terminating null character. /// /// Points to a variable that receives the product language. /// Points to a buffer that receives the product version. /// Points to a buffer that receives the product name. The buffer includes a terminating null character. /// /// Points to a variable that specifies the size, in characters, of the buffer pointed to by the lpNameBuf parameter. This size /// should include the terminating null character. When the function returns, this variable contains the length of the string stored /// in the buffer. The count returned does not include the terminating null character. If the buffer is not large enough, the /// function returns ERROR_MORE_DATA, and the variable contains the size of the string in characters, without counting the null character. /// /// Points to a buffer that receives the package name. The buffer includes the terminating null character. /// /// Points to a variable that specifies the size, in characters, of the buffer pointed to by the lpPackageNameBuf parameter. This /// size should include the terminating null character. When the function returns, this variable contains the length of the string /// stored in the buffer. The count returned does not include the terminating null character. If the buffer is not large enough, the /// function returns ERROR_MORE_DATA, and the variable contains the size of the string in characters, without counting the null character. /// /// /// /// /// Value /// Meaning /// /// /// ERROR_SUCCESS /// The function completed successfully. /// /// /// ERROR_INVALID_PARAMETER /// An invalid argument was passed to the function. /// /// /// ERROR_MORE_DATA /// A buffer was too small to hold the entire value. /// /// /// ERROR_INSTALL_FAILURE /// Could not get script information. /// /// /// ERROR_CALL_NOT_IMPLEMENTED /// This function is only available on Windows 2000 and Windows XP. /// /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msigetproductinfofromscripta UINT MsiGetProductInfoFromScriptA( // LPCSTR szScriptFile, LPSTR lpProductBuf39, LANGID *plgidLanguage, LPDWORD pdwVersion, LPSTR lpNameBuf, LPDWORD pcchNameBuf, LPSTR // lpPackageBuf, LPDWORD pcchPackageBuf ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiGetProductInfoFromScriptA")] public static extern Win32Error MsiGetProductInfoFromScript([MarshalAs(UnmanagedType.LPTStr)] string szScriptFile, [Out, Optional, MarshalAs(UnmanagedType.LPTStr)] StringBuilder lpProductBuf39, out ushort plgidLanguage, out uint pdwVersion, [Out, Optional, MarshalAs(UnmanagedType.LPTStr)] StringBuilder lpNameBuf, ref uint pcchNameBuf, [Out, Optional, MarshalAs(UnmanagedType.LPTStr)] StringBuilder lpPackageBuf, ref uint pcchPackageBuf); /// The MsiGetProductProperty function retrieves product properties. These properties are in the product database. /// Handle to the product obtained from MsiOpenProduct. /// Specifies the property to retrieve. This is case-sensitive. /// /// Pointer to a buffer that receives the property value. The value is truncated and null-terminated if lpValueBuf is too small. /// This parameter can be null. /// /// /// /// Pointer to a variable that specifies the size, in characters, of the buffer pointed to by the lpValueBuf parameter. On input, /// this is the full size of the buffer, including a space for a terminating null character. If the buffer passed in is too small, /// the count returned does not include the terminating null character. /// /// If lpValueBuf is null, pcchValueBuf can be null. /// /// /// The MsiGetProductProperty function return the following values. /// /// /// Value /// Meaning /// /// /// ERROR_INVALID_PARAMETER /// An invalid parameter was passed to the function. /// /// /// ERROR_INVALID_HANDLE /// An invalid handle was passed to the function. /// /// /// ERROR_MORE_DATA /// A buffer is too small to hold the entire property value. /// /// /// ERROR_SUCCESS /// The function completed successfully. /// /// /// /// /// When the MsiGetProductProperty function returns, the pcchValueBuf parameter contains the length of the string stored in /// the buffer. The count returned does not include the terminating null character. If the buffer is not big enough, /// MsiGetProductProperty returns ERROR_MORE_DATA, and MsiGetProductProperty contains the size of the string, in /// characters, without counting the null character. /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msigetproductpropertya UINT MsiGetProductPropertyA( MSIHANDLE // hProduct, LPCSTR szProperty, LPSTR lpValueBuf, LPDWORD pcchValueBuf ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiGetProductPropertyA")] public static extern Win32Error MsiGetProductProperty(MSIHANDLE hProduct, [MarshalAs(UnmanagedType.LPTStr)] string szProperty, [Out, Optional, MarshalAs(UnmanagedType.LPTStr)] StringBuilder lpValueBuf, ref uint pcchValueBuf); /// /// The MsiGetShortcutTarget function examines a shortcut and returns its product, feature name, and component if available. /// /// A null-terminated string specifying the full path to a shortcut. /// /// A GUID for the product code of the shortcut. This string buffer must be 39 characters long. The first 38 characters are for the /// GUID, and the last character is for the terminating null character. This parameter can be null. /// /// /// The feature name of the shortcut. The string buffer must be MAX_FEATURE_CHARS+1 characters long. This parameter can be null. /// /// /// A GUID of the component code. This string buffer must be 39 characters long. The first 38 characters are for the GUID, and the /// last character is for the terminating null character. This parameter can be null. /// /// This function returns UINT. /// /// /// If the function fails, and the shortcut exists, the regular contents of the shortcut may be accessed through the IShellLink interface. /// /// Otherwise, the state of the target may be determined by using the Installer Selection Functions. /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msigetshortcuttargeta UINT MsiGetShortcutTargetA( LPCSTR // szShortcutPath, LPSTR szProductCode, LPSTR szFeatureId, LPSTR szComponentCode ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiGetShortcutTargetA")] public static extern Win32Error MsiGetShortcutTarget([MarshalAs(UnmanagedType.LPTStr)] string szShortcutPath, [Out, Optional, MarshalAs(UnmanagedType.LPTStr)] StringBuilder szProductCode, [Out, Optional, MarshalAs(UnmanagedType.LPTStr)] StringBuilder szFeatureId, [Out, Optional, MarshalAs(UnmanagedType.LPTStr)] StringBuilder szComponentCode); /// The MsiGetUserInfo function returns the registered user information for an installed product. /// Specifies the product code for the product to be queried. /// Pointer to a variable that receives the name of the user. /// /// Pointer to a variable that specifies the size, in characters, of the buffer pointed to by the lpUserNameBuf parameter. This size /// should include the terminating null character. /// /// Pointer to a buffer that receives the organization name. /// /// Pointer to a variable that specifies the size, in characters, of the buffer pointed to by the lpOrgNameBuf parameter. On input, /// this is the full size of the buffer, including a space for a terminating null character. If the buffer passed in is too small, /// the count returned does not include the terminating null character. /// /// Pointer to a buffer that receives the product ID. /// /// Pointer to a variable that specifies the size, in characters, of the buffer pointed to by the lpSerialBuf parameter. On input, /// this is the full size of the buffer, including a space for a terminating null character. If the buffer passed in is too small, /// the count returned does not include the terminating null character. /// /// /// /// /// Value /// Meaning /// /// /// USERINFOSTATE_ABSENT /// Some or all of the user information is absent. /// /// /// USERINFOSTATE_INVALIDARG /// One of the function parameters was invalid. /// /// /// USERINFOSTATE_MOREDATA /// A buffer is too small to hold the requested data. /// /// /// USERINFOSTATE_PRESENT /// The function completed successfully. /// /// /// USERINFOSTATE_UNKNOWN /// The product code does not identify a known product. /// /// /// /// /// /// When the MsiGetUserInfo function returns, the pcchNameBuf parameter contains the length of the class string stored in the /// buffer. The count returned does not include the terminating null character. If the buffer is not big enough, the /// MsiGetUserInfo function returns USERINFOSTATE_MOREDATA, and MsiGetUserInfo contains the size of the string, in /// characters, without counting the null character. /// /// The user information is considered to be present even in the absence of a company name. /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msigetuserinfoa USERINFOSTATE MsiGetUserInfoA( LPCSTR szProduct, // LPSTR lpUserNameBuf, LPDWORD pcchUserNameBuf, LPSTR lpOrgNameBuf, LPDWORD pcchOrgNameBuf, LPSTR lpSerialBuf, LPDWORD // pcchSerialBuf ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiGetUserInfoA")] public static extern USERINFOSTATE MsiGetUserInfo([MarshalAs(UnmanagedType.LPTStr)] string szProduct, [Out, Optional, MarshalAs(UnmanagedType.LPTStr)] StringBuilder lpUserNameBuf, ref uint pcchUserNameBuf, [Out, Optional, MarshalAs(UnmanagedType.LPTStr)] StringBuilder lpOrgNameBuf, ref uint pcchOrgNameBuf, [Out, Optional, MarshalAs(UnmanagedType.LPTStr)] StringBuilder lpSerialBuf, ref uint pcchSerialBuf); /// The MsiInstallMissingComponent function installs files that are unexpectedly missing. /// Specifies the product code for the product that owns the component to be installed. /// Identifies the component to be installed. /// /// Specifies the way the component should be installed. This parameter must be one of the following values. /// /// /// Value /// Meaning /// /// /// INSTALLSTATE_LOCAL /// The component should be locally installed. /// /// /// INSTALLSTATE_SOURCE /// The component should be installed to run from the source. /// /// /// INSTALLSTATE_DEFAULT /// The component should be installed according to the installer defaults. /// /// /// /// /// /// /// Value /// Meaning /// /// /// ERROR_BAD_CONFIGURATION /// The configuration information is corrupt. /// /// /// ERROR_INSTALL_FAILURE /// The installation failed. /// /// /// ERROR_INSTALL_SOURCE_ABSENT /// The source was unavailable. /// /// /// ERROR_INSTALL_SUSPEND /// The installation was suspended. /// /// /// ERROR_INSTALL_USEREXIT /// The user exited the installation. /// /// /// ERROR_INVALID_PARAMETER /// One of the parameters is invalid. /// /// /// ERROR_SUCCESS /// The function completed successfully. /// /// /// ERROR_UNKNOWN_PRODUCT /// The product code is unrecognized. /// /// /// For more information about error messages, see Displayed Error Messages /// /// /// The MsiInstallMissingComponent function resolves the feature(s) that the component belongs to. Then, the product feature /// that requires the least additional disk space is installed. /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msiinstallmissingcomponenta UINT MsiInstallMissingComponentA( // LPCSTR szProduct, LPCSTR szComponent, INSTALLSTATE eInstallState ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiInstallMissingComponentA")] public static extern Win32Error MsiInstallMissingComponent([MarshalAs(UnmanagedType.LPTStr)] string szProduct, [MarshalAs(UnmanagedType.LPTStr)] string szComponent, INSTALLSTATE eInstallState); /// The MsiInstallMissingFile function installs files that are unexpectedly missing. /// Specifies the product code for the product that owns the file to be installed. /// Specifies the file to be installed. /// /// /// /// Value /// Meaning /// /// /// ERROR_BAD_CONFIGURATION /// The configuration information is corrupt. /// /// /// ERROR_INSTALL_FAILURE /// The installation failed. /// /// /// ERROR_INSTALL_SOURCE_ABSENT /// The source was unavailable. /// /// /// ERROR_INSTALL_SUSPEND /// The installation was suspended. /// /// /// ERROR_INSTALL_USEREXIT /// The user exited the installation. /// /// /// ERROR_INVALID_PARAMETER /// A parameter was invalid. /// /// /// ERROR_SUCCESS /// The function completed successfully. /// /// /// ERROR_UNKNOWN_PRODUCT /// The product code is unrecognized. /// /// /// For more information about error messages, see Displayed Error Messages. /// /// /// The MsiInstallMissingFile function obtains the component that the file belongs to from the file table. Then, the product /// feature that requires the least additional disk space is installed. /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msiinstallmissingfilea UINT MsiInstallMissingFileA( LPCSTR // szProduct, LPCSTR szFile ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiInstallMissingFileA")] public static extern Win32Error MsiInstallMissingFile([MarshalAs(UnmanagedType.LPTStr)] string szProduct, [MarshalAs(UnmanagedType.LPTStr)] string szFile); /// The MsiInstallProduct function installs or uninstalls a product. /// /// A null-terminated string that specifies the path to the location of the Windows Installer package. The string value can contain /// a URL (e.g. http://packageLocation/package/package.msi), a network path (e.g. \packageLocation\package.msi), a file path /// (e.g. file://packageLocation/package.msi), or a local path (e.g. D:\packageLocation\package.msi). /// /// /// /// A null-terminated string that specifies the command line property settings. This should be a list of the format Property=Setting /// Property=Setting. For more information, see About Properties. /// /// /// To perform an administrative installation, include ACTION=ADMIN in szCommandLine. For more information, see the ACTION property. /// /// /// /// /// /// Value /// Meaning /// /// /// ERROR_SUCCESS /// The function completes successfully. /// /// /// An error relating to an action /// For more information, see Error Codes. /// /// /// Initialization Error /// An error that relates to initialization occurred. /// /// /// For more information, see Displayed Error Messages. /// /// /// The MsiInstallProduct function displays the user interface with the current settings and log mode. /// /// /// You can change user interface settings by using the MsiSetInternalUI, MsiSetExternalUI, or MsiSetExternalUIRecord functions. /// /// /// You can set the log mode by using the MsiEnableLog function. /// /// /// You can completely remove a product by setting REMOVE=ALL in szCommandLine. /// /// /// For more information, see REMOVE Property. /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msiinstallproducta UINT MsiInstallProductA( LPCSTR szPackagePath, // LPCSTR szCommandLine ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiInstallProductA")] public static extern Win32Error MsiInstallProduct([MarshalAs(UnmanagedType.LPTStr)] string szPackagePath, [Optional, MarshalAs(UnmanagedType.LPTStr)] string szCommandLine); /// /// /// The MsiIsProductElevated function returns whether or not the product is managed. Only applications that require elevated /// privileges for installation and being installed through advertisement are considered managed, which means that an application /// installed per-machine is always considered managed. /// /// /// An application that is installed per-user is only considered managed if it is advertised by a local system process that is /// impersonating the user. For more information, see Advertising a Per-User Application to be Installed with Elevated Privileges. /// /// /// MsiIsProductElevated verifies that the local system owns the product registry data. The function does not refer to /// account policies such as AlwaysInstallElevated. /// /// /// /// The full product code GUID of the product. /// This parameter is required and cannot be NULL or empty. /// /// /// A pointer to a BOOL for the result. /// This parameter cannot be NULL. /// /// /// /// If the function succeeds, the return value is ERROR_SUCCESS, and pfElevated is set to TRUE if the product is a managed application. /// /// If the function fails, the return value is one of the error codes identified in the following table. /// /// /// Return code /// Description /// /// /// ERROR_UNKNOWN_PRODUCT /// The product is not currently known. /// /// /// ERROR_INVALID_PARAMETER /// An invalid argument is passed to the function. /// /// /// ERROR_BAD_CONFIGURATION /// The configuration information for the product is invalid. /// /// /// ERROR_FUNCTION_FAILED /// The function failed. /// /// /// ERROR_CALL_NOT_IMPLEMENTED /// The function is not available for a specific platform. /// /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msiisproductelevatedw UINT MsiIsProductElevatedW( LPCWSTR // szProduct, BOOL *pfElevated ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiIsProductElevatedW")] public static extern Win32Error MsiIsProductElevated([MarshalAs(UnmanagedType.LPTStr)] string szProduct, [MarshalAs(UnmanagedType.Bool)] out bool pfElevated); /// /// /// The MsiJoinTransaction function requests that the Windows Installer make the current process the owner of the transaction /// installing the multiple-package installation. /// /// Windows Installer 4.0 and earlier: Not supported. This function is available beginning with Windows Installer 4.5. /// /// /// The transaction ID, which identifies the transaction and is the identifier returned by the MsiBeginTransaction function. /// /// /// Attributes of the multiple-package installation. /// /// /// Value /// Meaning /// /// /// 0 /// When 0 or no value is set, Windows Installer closes the UI from the previous installation. /// /// /// MSITRANSACTION_CHAIN_EMBEDDEDUI /// Set this attribute to request that the Windows Installer not shutdown the embedded UI until the transaction is complete. /// /// /// MSITRANSACTION_JOIN_EXISTING_EMBEDDEDUI /// /// Set this attribute to request that the Windows Installer transfer the embedded UI from the original installation. If the /// original installation has no embedded UI, setting this attribute does nothing. /// /// /// /// /// /// This parameter returns a handle to an event that is set when the MsiJoinTransaction function changes the owner of the /// transaction to a new owner. The current owner can use this to determine when ownership of the transaction has changed. Leaving a /// transaction without an owner will roll back the transaction. /// /// /// The MsiJoinTransaction function can return the following values. /// /// /// Value /// Meaning /// /// /// ERROR_ACCESS_DENIED /// The user that owns the transaction and the user that joins the transaction are not the same. /// /// /// ERROR_INVALID_PARAMETER /// A parameter that is not valid is passed to the function. /// /// /// ERROR_INSTALL_ALREADY_RUNNING /// The owner cannot be changed while an active installation is in progress. /// /// /// ERROR_INVALID_HANDLE_STATE /// The transaction ID provided is not valid. /// /// /// /// /// /// Because a transaction can be owned by no more than one process at a time, the functions authored into the MsiEmbeddedChainer /// table can use MsiJoinTransaction to request ownership of the transaction before using the Windows Installer API to /// configure or install an application. The installer verifies that there is no installation in progress. The installer verifies /// that the process requesting ownership and the process that currently owns the transaction share a parent process in the same /// process tree. If the function succeeds, the process that calls MsiJoinTransaction becomes the current owner of the transaction. /// /// /// MsiJoinTransaction sets the internal UI of the new installation to the UI level of thew original installation. After the /// new installation owns the transaction, it can call MsiSetInternalUI to change the UI level. This enables the new installation to /// run at a higher UI level than the original installation. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msijointransaction UINT MsiJoinTransaction( MSIHANDLE // hTransactionHandle, DWORD dwTransactionAttributes, HANDLE *phChangeOfOwnerEvent ); [DllImport(Lib_Msi, SetLastError = false, ExactSpelling = true)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiJoinTransaction")] public static extern Win32Error MsiJoinTransaction(MSIHANDLE hTransactionHandle, MSITRANSACTION dwTransactionAttributes, out System.Threading.EventWaitHandle phChangeOfOwnerEvent); /// /// The MsiLocateComponent function returns the full path to an installed component without a product code. This function /// attempts to determine the product using MsiGetProductCode, but is not guaranteed to find the correct product for the caller. /// MsiGetComponentPath should always be called when possible. /// /// Specifies the component ID of the component to be located. /// /// Pointer to a variable that receives the path to the component. The variable includes the terminating null character. /// /// /// /// Pointer to a variable that specifies the size, in characters, of the buffer pointed to by the lpPathBuf parameter. On input, /// this is the full size of the buffer, including a space for a terminating null character. Upon success of the /// MsiLocateComponent function, the variable pointed to by pcchBuf contains the count of characters not including the /// terminating null character. If the size of the buffer passed in is too small, the function returns INSTALLSTATE_MOREDATA. /// /// If lpPathBuf is null, pcchBuf can be null. /// /// /// /// /// Value /// Meaning /// /// /// INSTALLSTATE_NOTUSED /// The component being requested is disabled on the computer. /// /// /// INSTALLSTATE_ABSENT /// The component is not installed. See Remarks. /// /// /// INSTALLSTATE_INVALIDARG /// One of the function parameters is invalid. /// /// /// INSTALLSTATE_LOCAL /// The component is installed locally. /// /// /// INSTALLSTATE_MOREDATA /// The buffer provided was too small. /// /// /// INSTALLSTATE_SOURCE /// The component is installed to run from source. /// /// /// INSTALLSTATE_SOURCEABSENT /// The component source is inaccessible. /// /// /// INSTALLSTATE_UNKNOWN /// The product code or component ID is unknown. See Remarks. /// /// /// /// /// The MsiLocateComponent function might return INSTALLSTATE_ABSENT or INSTALL_STATE_UNKNOWN, for the following reasons: /// /// /// INSTALLSTATE_ABSENT /// /// The application did not properly ensure that the feature was installed by calling MsiUseFeature and, if necessary, MsiConfigureFeature. /// /// /// /// INSTALLSTATE_UNKNOWN /// /// The feature is not published. The application should have determined this earlier by calling MsiQueryFeatureState or /// MsiEnumFeatures. The application makes these calls while it initializes. An application should only use features that are known /// to be published. Since INSTALLSTATE_UNKNOWN should have been returned by MsiUseFeature as well, either MsiUseFeature was not /// called, or its return value was not properly checked. /// /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msilocatecomponenta INSTALLSTATE MsiLocateComponentA( LPCSTR // szComponent, LPSTR lpPathBuf, LPDWORD pcchBuf ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiLocateComponentA")] public static extern INSTALLSTATE MsiLocateComponent([MarshalAs(UnmanagedType.LPTStr)] string szComponent, [Out, Optional, MarshalAs(UnmanagedType.LPTStr)] StringBuilder lpPathBuf, ref uint pcchBuf); /// /// The MsiNotifySidChange function notifies and updates the Windows Installer internal information with changes to user SIDs. /// /// Null-terminated string that specifies the string value of the previous security identifier(SID). /// Null-terminated string that specifies the string value of the new security identifier(SID). /// /// /// /// Value /// Meaning /// /// /// ERROR_INVALID_PARAMETER /// An invalid parameter is passed to the function. This error returned if any of the parameters is NULL. /// /// /// ERROR_SUCCESS /// The function succeeded. /// /// /// ERROR_OUTOFMEMORY /// Insufficient memory was available. /// /// /// ERROR_FUNCTION_FAILED /// Internal failure during execution. /// /// /// /// /// Windows Installer 2.0 and Windows Installer 3.0: Not supported. This function is available beginning with Windows /// Installer 3.1. /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msinotifysidchangea UINT MsiNotifySidChangeA( LPCSTR pOldSid, // LPCSTR pNewSid ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiNotifySidChangeA")] public static extern Win32Error MsiNotifySidChange([MarshalAs(UnmanagedType.LPTStr)] string pOldSid, [MarshalAs(UnmanagedType.LPTStr)] string pNewSid); /// /// The MsiOpenPackage function opens a package to use with the functions that access the product database. The /// MsiCloseHandle function must be called with the handle when the handle is not needed. /// /// The path to the package. /// A pointer to a variable that receives the product handle. /// /// /// /// Value /// Meaning /// /// /// ERROR_BAD_CONFIGURATION /// The configuration information is corrupt. /// /// /// ERROR_INSTALL_FAILURE /// The product could not be opened. /// /// /// ERROR_INSTALL_REMOTE_PROHIBITED /// Windows Installer does not permit installation from a remote desktop connection. /// /// /// ERROR_INVALID_PARAMETER /// An invalid parameter is passed to the function. /// /// /// ERROR_SUCCESS /// The function completes successfully. /// /// /// If this function fails, it may return a system error code. For more information, see System Error Codes. /// /// /// MsiOpenPackage can accept an opened database handle in the form "#nnnn", where nnnn is the database handle in string form, i.e. /// #123, instead of a path to the package. This is intended for development tasks such as running validation actions, or for use /// with database management tools. /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msiopenpackagea UINT MsiOpenPackageA( LPCSTR szPackagePath, // MSIHANDLE *hProduct ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiOpenPackageA")] public static extern Win32Error MsiOpenPackage([MarshalAs(UnmanagedType.LPTStr)] string szPackagePath, out PMSIHANDLE hProduct); /// /// The MsiOpenPackageEx function opens a package to use with functions that access the product database. The MsiCloseHandle /// function must be called with the handle when the handle is no longer needed. /// /// The path to the package. /// /// The bit flags to indicate whether or not to ignore the computer state. Pass in 0 (zero) to use MsiOpenPackage behavior. /// /// /// Constant /// Meaning /// /// /// MSIOPENPACKAGEFLAGS_IGNOREMACHINESTATE 1 /// Ignore the computer state when creating the product handle. /// /// /// /// A pointer to a variable that receives the product handle. /// /// /// /// Value /// Meaning /// /// /// ERROR_BAD_CONFIGURATION /// The configuration information is corrupt. /// /// /// ERROR_INSTALL_FAILURE /// The product could not be opened. /// /// /// ERROR_INSTALL_REMOTE_PROHIBITED /// Windows Installer does not permit installation from a remote desktop connection. /// /// /// ERROR_INVALID_PARAMETER /// An invalid parameter is passed to the function. /// /// /// ERROR_SUCCESS /// The function completes successfully. /// /// /// If this function fails, it may return a system error code. For more information, see System Error Codes. /// /// /// /// To create a restricted product handle that is independent of the current machine state and incapable of changing the current /// machine state, use MsiOpenPackageEx with MSIOPENPACKAGEFLAGS_IGNOREMACHINESTATE set in dwOptions. /// /// /// Note that if dwOptions is MSIOPENPACKAGEFLAGS_IGNOREMACHINESTATE or 1, MsiOpenPackageEx ignores the current machine state /// when creating the product handle. If the value of dwOptions is 0, MsiOpenPackageEx is the same as MsiOpenPackage and /// creates a product handle that is dependent upon whether the package specified by szPackagePath is already installed on the computer. /// /// /// The restricted handle created by using MsiOpenPackageEx with MSIOPENPACKAGEFLAGS_IGNOREMACHINESTATE only permits /// execution of dialogs, a subset of the standard actions, and custom actions that set properties ( Custom Action Type 35, Custom /// Action Type 51, and Custom Action Type 19). The restricted handle prevents the use of custom actions that run Dynamic-Link /// Libraries, Executable Files or Scripts. /// /// /// You can call MsiDoAction on the following standard actions using the restricted handle. All other actions return /// ERROR_FUNCTION_NOT_CALLED if called with the restricted handle. /// /// /// /// ADMIN /// /// /// ADVERTISE /// /// /// INSTALL /// /// /// SEQUENCE /// /// /// AppSearch action /// /// /// CCPSearch /// /// /// CostFinalize /// /// /// CostInitialize /// /// /// FileCost /// /// /// FindRelatedProducts /// /// /// IsolateComponents action /// /// /// LaunchConditions /// /// /// MigrateFeatureStates /// /// /// ResolveSource /// /// /// RMCCPSearch /// /// /// ValidateProductID /// /// /// The MsiCloseHandle function must be called when the handle is not needed. /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msiopenpackageexa UINT MsiOpenPackageExA( LPCSTR szPackagePath, // DWORD dwOptions, MSIHANDLE *hProduct ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiOpenPackageExA")] public static extern Win32Error MsiOpenPackageEx([MarshalAs(UnmanagedType.LPTStr)] string szPackagePath, MSIOPENPACKAGEFLAGS dwOptions, out PMSIHANDLE hProduct); /// /// /// The MsiOpenProduct function opens a product for use with the functions that access the product database. The /// MsiCloseHandle function must be called with the handle when the handle is no longer needed. /// /// /// Note Initialize COM on the same thread before calling the MsiOpenPackage, MsiOpenPackageEx, or MsiOpenProduct function. /// /// /// Specifies the product code of the product to be opened. /// Pointer to a variable that receives the product handle. /// /// /// /// Value /// Meaning /// /// /// ERROR_BAD_CONFIGURATION /// The configuration information is corrupt. /// /// /// ERROR_INSTALL_FAILURE /// The product could not be opened. /// /// /// ERROR_INSTALL_SOURCE_ABSENT /// The source was unavailable. /// /// /// ERROR_INVALID_PARAMETER /// An invalid parameter was passed to the function. /// /// /// ERROR_SUCCESS /// The function completed successfully. /// /// /// ERROR_UNKNOWN_PRODUCT /// The product code was unrecognized. /// /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msiopenproducta UINT MsiOpenProductA( LPCSTR szProduct, MSIHANDLE // *hProduct ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiOpenProductA")] public static extern Win32Error MsiOpenProduct([MarshalAs(UnmanagedType.LPTStr)] string szProduct, out PMSIHANDLE hProduct); /// The MsiProcessAdvertiseScript function processes an advertise script file into the specified locations. /// The full path to a script file generated by MsiAdvertiseProduct or MsiAdvertiseProductEx. /// /// An optional path to a folder in which advertised icon files and transform files are located. If this parameter is NULL, /// no icon or transform files are written. /// /// /// A registry key under which registry data is to be written. If this parameter is NULL, the installer writes the registry /// data under the appropriate key, based on whether the advertisement is per-user or per-machine. If this parameter is non- /// NULL, the script will write the registry data under the specified registry key rather than the normal location. In this /// case, the application will not get advertised to the user. /// /// /// TRUE if shortcuts should be created. If a special folder is returned by SHGetSpecialFolderLocation it will hold the shortcuts. /// /// TRUE if specified items are to be removed instead of created. /// /// /// /// Value /// Meaning /// /// /// ERROR_SUCCESS /// The function completed successfully. /// /// /// ERROR_ACCESS_DENIED /// The calling process was not running under the LocalSystem account. /// /// /// An error relating to an action /// See Error Codes. /// /// /// Initialization Error /// An error relating to initialization occurred. /// /// /// ERROR_CALL_NOT_IMPLEMENTED /// This function is not available for this platform. /// /// /// /// /// The process calling this function must be running under the LocalSystem account. To advertise an application for per-user /// installation to a targeted user, the thread that calls this function must impersonate the targeted user. If the thread calling /// this function is not impersonating a targeted user, the application is advertised to all users for installation with elevated privileges. /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msiprocessadvertisescripta UINT MsiProcessAdvertiseScriptA( LPCSTR // szScriptFile, LPCSTR szIconFolder, HKEY hRegData, BOOL fShortcuts, BOOL fRemoveItems ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiProcessAdvertiseScriptA")] public static extern Win32Error MsiProcessAdvertiseScript([MarshalAs(UnmanagedType.LPTStr)] string szScriptFile, [Optional, MarshalAs(UnmanagedType.LPTStr)] string szIconFolder, HKEY hRegData, [MarshalAs(UnmanagedType.Bool)] bool fShortcuts, [MarshalAs(UnmanagedType.Bool)] bool fRemoveItems); /// /// The MsiProvideAssembly function returns the full path to a Windows Installer component that contains an assembly. The /// function prompts for a source and performs any necessary installation. MsiProvideAssembly increments the usage count for /// the feature. /// /// The assembly name as a string. /// /// Set to null for global assemblies. For private assemblies, set szAppContext to the full path of the application configuration /// file or to the full path of the executable file of the application to which the assembly has been made private. /// /// /// Defines the installation mode. This parameter can be one of the following values. /// /// /// Value /// Meaning /// /// /// INSTALLMODE_DEFAULT /// /// Provide the component and perform any installation necessary to provide the component. If the key file of a component in the /// requested feature, or a feature parent, is missing, reinstall the feature using MsiReinstallFeature with the following flag bits /// set: REINSTALLMODE_FILEMISSING, REINSTALLMODE_FILEOLDERVERSION, REINSTALLMODE_FILEVERIFY, REINSTALLMODE_MACHINEDATA, /// REINSTALLMODE_USERDATA and REINSTALLMODE_SHORTCUT. /// /// /// /// INSTALLMODE_EXISTING /// /// Provide the component only if the feature exists. Otherwise return ERROR_FILE_NOT_FOUND. This mode verifies that the key file of /// the component exists. /// /// /// /// INSTALLMODE_NODETECTION /// /// Provide the component only if the feature exists. Otherwise return ERROR_FILE_NOT_FOUND. This mode only checks that the /// component is registered and does not verify that the key file of the component exists. /// /// /// /// INSTALLMODE_NOSOURCERESOLUTION /// /// Provide the component only if the feature's installation state is INSTALLSTATE_LOCAL. If the feature installation state is /// INSTALLSTATE_SOURCE, return ERROR_INSTALL_SOURCE_ABSENT. Otherwise return ERROR_FILE_NOT_FOUND. This mode only checks that the /// component is registered and does not verify that the key file exists. /// /// /// /// INSTALLMODE_NODETECTION_ANY /// /// Provide the component if a feature exists from any installed product. Otherwise return ERROR_FILE_NOT_FOUND. This mode only /// checks that the component is registered and does not verify that the key file of the component exists. This flag is similar to /// the INSTALLMODE_NODETECTION flag except that with this flag we check for any product that has installed the assembly as opposed /// to the last product as is the case with the INSTALLMODE_NODETECTION flag. This flag can only be used with MsiProvideAssembly. /// /// /// /// combination of the REINSTALLMODE flags /// /// Call MsiReinstallFeature to reinstall feature using this parameter for the dwReinstallMode parameter, and then provide the component. /// /// /// /// /// /// Assembly information and assembly type. Set to one of the following values. /// /// /// Value /// Meaning /// /// /// MSIASSEMBLYINFO_NETASSEMBLY 0 /// .NET Assembly /// /// /// MSIASSEMBLYINFO_WIN32ASSEMBLY 1 /// Win32 Assembly /// /// /// /// Pointer to a variable that receives the path to the component. This parameter can be null. /// /// /// Pointer to a variable that specifies the size, in characters, of the buffer pointed to by the lpPathBuf parameter. On input, /// this is the full size of the buffer, including a space for a terminating null character. If the buffer passed in is too small, /// the count returned does not include the terminating null character. /// /// If lpPathBuf is null, pcchPathBuf can be null. /// /// /// /// /// Value /// Meaning /// /// /// ERROR_BAD_CONFIGURATION /// The configuration data is corrupt. /// /// /// ERROR_FILE_NOT_FOUND /// The feature is absent or broken. This error is returned for dwInstallMode = INSTALLMODE_EXISTING. /// /// /// ERROR_INSTALL_FAILURE /// The installation failed. /// /// /// ERROR_INSTALL_NOTUSED /// The component being requested is disabled on the computer. /// /// /// ERROR_INVALID_PARAMETER /// An invalid parameter was passed to the function. /// /// /// ERROR_SUCCESS /// The function completed successfully. /// /// /// ERROR_UNKNOWN_FEATURE /// The feature ID does not identify a known feature. /// /// /// ERROR_UNKNOWN_COMPONENT /// The component ID does not specify a known component. /// /// /// ERROR_UNKNOWN_PRODUCT /// The product code does not identify a known product. /// /// /// INSTALLSTATE_UNKNOWN /// An unrecognized product or a feature name was passed to the function. /// /// /// ERROR_MORE_DATA /// The buffer overflow is returned. /// /// /// ERROR_NOT_ENOUGH_MEMORY /// The system does not have enough memory to complete the operation. Available with Windows Server 2003. /// /// /// ERROR_INSTALL_SOURCE_ABSENT /// Unable to detect a source. /// /// /// For more information, see Displayed Error Messages. /// /// /// When the MsiProvideAssembly function succeeds, the pcchPathBuf parameter contains the length of the string in lpPathBuf. /// The INSTALLMODE_EXISTING option cannot be used in combination with the REINSTALLMODE flag. /// /// Features with components that contain a corrupted file or the wrong version of a file must be explicitly reinstalled by the /// user, or by having the application call MsiReinstallFeature. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msiprovideassemblya UINT MsiProvideAssemblyA( LPCSTR // szAssemblyName, LPCSTR szAppContext, DWORD dwInstallMode, DWORD dwAssemblyInfo, LPSTR lpPathBuf, LPDWORD pcchPathBuf ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiProvideAssemblyA")] public static extern Win32Error MsiProvideAssembly([MarshalAs(UnmanagedType.LPTStr)] string szAssemblyName, [Optional, MarshalAs(UnmanagedType.LPTStr)] string szAppContext, INSTALLMODE dwInstallMode, MSIASSEMBLYINFO dwAssemblyInfo, [Out, Optional, MarshalAs(UnmanagedType.LPTStr)] StringBuilder lpPathBuf, ref uint pcchPathBuf); /// /// The MsiProvideAssembly function returns the full path to a Windows Installer component that contains an assembly. The /// function prompts for a source and performs any necessary installation. MsiProvideAssembly increments the usage count for /// the feature. /// /// The assembly name as a string. /// /// Set to null for global assemblies. For private assemblies, set szAppContext to the full path of the application configuration /// file or to the full path of the executable file of the application to which the assembly has been made private. /// /// /// Defines the installation mode. This parameter can be one of the following values. /// /// /// Value /// Meaning /// /// /// INSTALLMODE_DEFAULT /// /// Provide the component and perform any installation necessary to provide the component. If the key file of a component in the /// requested feature, or a feature parent, is missing, reinstall the feature using MsiReinstallFeature with the following flag bits /// set: REINSTALLMODE_FILEMISSING, REINSTALLMODE_FILEOLDERVERSION, REINSTALLMODE_FILEVERIFY, REINSTALLMODE_MACHINEDATA, /// REINSTALLMODE_USERDATA and REINSTALLMODE_SHORTCUT. /// /// /// /// INSTALLMODE_EXISTING /// /// Provide the component only if the feature exists. Otherwise return ERROR_FILE_NOT_FOUND. This mode verifies that the key file of /// the component exists. /// /// /// /// INSTALLMODE_NODETECTION /// /// Provide the component only if the feature exists. Otherwise return ERROR_FILE_NOT_FOUND. This mode only checks that the /// component is registered and does not verify that the key file of the component exists. /// /// /// /// INSTALLMODE_NOSOURCERESOLUTION /// /// Provide the component only if the feature's installation state is INSTALLSTATE_LOCAL. If the feature installation state is /// INSTALLSTATE_SOURCE, return ERROR_INSTALL_SOURCE_ABSENT. Otherwise return ERROR_FILE_NOT_FOUND. This mode only checks that the /// component is registered and does not verify that the key file exists. /// /// /// /// INSTALLMODE_NODETECTION_ANY /// /// Provide the component if a feature exists from any installed product. Otherwise return ERROR_FILE_NOT_FOUND. This mode only /// checks that the component is registered and does not verify that the key file of the component exists. This flag is similar to /// the INSTALLMODE_NODETECTION flag except that with this flag we check for any product that has installed the assembly as opposed /// to the last product as is the case with the INSTALLMODE_NODETECTION flag. This flag can only be used with MsiProvideAssembly. /// /// /// /// combination of the REINSTALLMODE flags /// /// Call MsiReinstallFeature to reinstall feature using this parameter for the dwReinstallMode parameter, and then provide the component. /// /// /// /// /// /// Assembly information and assembly type. Set to one of the following values. /// /// /// Value /// Meaning /// /// /// MSIASSEMBLYINFO_NETASSEMBLY 0 /// .NET Assembly /// /// /// MSIASSEMBLYINFO_WIN32ASSEMBLY 1 /// Win32 Assembly /// /// /// /// Pointer to a variable that receives the path to the component. This parameter can be null. /// /// /// Pointer to a variable that specifies the size, in characters, of the buffer pointed to by the lpPathBuf parameter. On input, /// this is the full size of the buffer, including a space for a terminating null character. If the buffer passed in is too small, /// the count returned does not include the terminating null character. /// /// If lpPathBuf is null, pcchPathBuf can be null. /// /// /// /// /// Value /// Meaning /// /// /// ERROR_BAD_CONFIGURATION /// The configuration data is corrupt. /// /// /// ERROR_FILE_NOT_FOUND /// The feature is absent or broken. This error is returned for dwInstallMode = INSTALLMODE_EXISTING. /// /// /// ERROR_INSTALL_FAILURE /// The installation failed. /// /// /// ERROR_INSTALL_NOTUSED /// The component being requested is disabled on the computer. /// /// /// ERROR_INVALID_PARAMETER /// An invalid parameter was passed to the function. /// /// /// ERROR_SUCCESS /// The function completed successfully. /// /// /// ERROR_UNKNOWN_FEATURE /// The feature ID does not identify a known feature. /// /// /// ERROR_UNKNOWN_COMPONENT /// The component ID does not specify a known component. /// /// /// ERROR_UNKNOWN_PRODUCT /// The product code does not identify a known product. /// /// /// INSTALLSTATE_UNKNOWN /// An unrecognized product or a feature name was passed to the function. /// /// /// ERROR_MORE_DATA /// The buffer overflow is returned. /// /// /// ERROR_NOT_ENOUGH_MEMORY /// The system does not have enough memory to complete the operation. Available with Windows Server 2003. /// /// /// ERROR_INSTALL_SOURCE_ABSENT /// Unable to detect a source. /// /// /// For more information, see Displayed Error Messages. /// /// /// When the MsiProvideAssembly function succeeds, the pcchPathBuf parameter contains the length of the string in lpPathBuf. /// The INSTALLMODE_EXISTING option cannot be used in combination with the REINSTALLMODE flag. /// /// Features with components that contain a corrupted file or the wrong version of a file must be explicitly reinstalled by the /// user, or by having the application call MsiReinstallFeature. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msiprovideassemblya UINT MsiProvideAssemblyA( LPCSTR // szAssemblyName, LPCSTR szAppContext, DWORD dwInstallMode, DWORD dwAssemblyInfo, LPSTR lpPathBuf, LPDWORD pcchPathBuf ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiProvideAssemblyA")] public static extern Win32Error MsiProvideAssembly([MarshalAs(UnmanagedType.LPTStr)] string szAssemblyName, [Optional, MarshalAs(UnmanagedType.LPTStr)] string szAppContext, INSTALLMODE dwInstallMode, MSIASSEMBLYINFO dwAssemblyInfo, [Out, Optional, MarshalAs(UnmanagedType.LPTStr)] StringBuilder lpPathBuf, [In, Optional] IntPtr pcchPathBuf); /// /// The MsiProvideComponent function returns the full component path, performing any necessary installation. This function /// prompts for source if necessary and increments the usage count for the feature. /// /// Specifies the product code for the product that contains the feature with the necessary component. /// Specifies the feature ID of the feature with the necessary component. /// Specifies the component code of the necessary component. /// /// Defines the installation mode. This parameter can be one of the following values. /// /// /// Value /// Meaning /// /// /// INSTALLMODE_DEFAULT /// /// Provide the component and perform any installation necessary to provide the component. If the key file of a component in the /// requested feature, or a feature parent, is missing, reinstall the feature using MsiReinstallFeature with the following flag bits /// set: REINSTALLMODE_FILEMISSING, REINSTALLMODE_FILEOLDERVERSION, REINSTALLMODE_FILEVERIFY, REINSTALLMODE_MACHINEDATA, /// REINSTALLMODE_USERDATA and REINSTALLMODE_SHORTCUT. /// /// /// /// INSTALLMODE_EXISTING /// /// Provide the component only if the feature exists. Otherwise return ERROR_FILE_NOT_FOUND. This mode verifies that the key file of /// the component exists. /// /// /// /// INSTALLMODE_NODETECTION /// /// Provide the component only if the feature exists. Otherwise return ERROR_FILE_NOT_FOUND. This mode only checks that the /// component is registered and does not verify that the key file of the component exists. /// /// /// /// combination of the REINSTALLMODE flags /// /// Call MsiReinstallFeature to reinstall feature using this parameter for the dwReinstallMode parameter, and then provide the component. /// /// /// /// INSTALLMODE_NOSOURCERESOLUTION /// /// Provide the component only if the feature's installation state is INSTALLSTATE_LOCAL. If the feature's installation state is /// INSTALLSTATE_SOURCE, return ERROR_INSTALL_SOURCE_ABSENT. Otherwise return ERROR_FILE_NOT_FOUND. This mode only checks that the /// component is registered and does not verify that the key file exists. /// /// /// /// /// Pointer to a variable that receives the path to the component. This parameter can be null. /// /// /// Pointer to a variable that specifies the size, in characters, of the buffer pointed to by the lpPathBuf parameter. On input, /// this is the full size of the buffer, including a space for a terminating null character. If the buffer passed in is too small, /// the count returned does not include the terminating null character. /// /// If lpPathBuf is null, pcchBuf can be null. /// /// /// /// /// Value /// Meaning /// /// /// ERROR_BAD_CONFIGURATION /// The configuration data is corrupt. /// /// /// ERROR_FILE_NOT_FOUND /// The feature is absent or broken. this error is returned for dwInstallMode = INSTALLMODE_EXISTING. /// /// /// ERROR_INSTALL_FAILURE /// The installation failed. /// /// /// ERROR_INSTALL_NOTUSED /// The component being requested is disabled on the computer. /// /// /// ERROR_INVALID_PARAMETER /// An invalid parameter was passed to the function. /// /// /// ERROR_SUCCESS /// The function completed successfully. /// /// /// ERROR_UNKNOWN_FEATURE /// The feature ID does not identify a known feature. /// /// /// ERROR_UNKNOWN_PRODUCT /// The product code does not identify a known product. /// /// /// INSTALLSTATE_UNKNOWN /// An unrecognized product or a feature name was passed to the function. /// /// /// ERROR_MORE_DATA /// The buffer overflow is returned. /// /// /// ERROR_INSTALL_SOURCE_ABSENT /// Unable to detect a source. /// /// /// For more information, see Displayed Error Messages. /// /// /// /// Upon success of the MsiProvideComponent function, the pcchPathBuf parameter contains the length of the string in lpPathBuf. /// /// /// The MsiProvideComponent function combines the functionality of MsiUseFeature, MsiConfigureFeature, and /// MsiGetComponentPath. You can use the MsiProvideComponent function to simplify the calling sequence. However, because this /// function increments the usage count, use it with caution to prevent inaccurate usage counts. The MsiProvideComponent /// function also provides less flexibility than the series of individual calls. /// /// /// If the application is recovering from an unexpected situation, the application has probably already called MsiUseFeature and /// incremented the usage count. In this case, the application should call MsiConfigureFeature instead of MsiProvideComponent /// to avoid incrementing the count again. /// /// The INSTALLMODE_EXISTING option cannot be used in combination with the REINSTALLMODE flag. /// /// Features with components containing a corrupted file or the wrong version of a file must be explicitly reinstalled by the user /// or by having the application call MsiReinstallFeature. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msiprovidecomponenta UINT MsiProvideComponentA( LPCSTR szProduct, // LPCSTR szFeature, LPCSTR szComponent, DWORD dwInstallMode, LPSTR lpPathBuf, LPDWORD pcchPathBuf ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiProvideComponentA")] public static extern Win32Error MsiProvideComponent([MarshalAs(UnmanagedType.LPTStr)] string szProduct, [MarshalAs(UnmanagedType.LPTStr)] string szFeature, [MarshalAs(UnmanagedType.LPTStr)] string szComponent, INSTALLMODE dwInstallMode, [Out, Optional, MarshalAs(UnmanagedType.LPTStr)] StringBuilder lpPathBuf, ref uint pcchPathBuf); /// /// The MsiProvideComponent function returns the full component path, performing any necessary installation. This function /// prompts for source if necessary and increments the usage count for the feature. /// /// Specifies the product code for the product that contains the feature with the necessary component. /// Specifies the feature ID of the feature with the necessary component. /// Specifies the component code of the necessary component. /// /// Defines the installation mode. This parameter can be one of the following values. /// /// /// Value /// Meaning /// /// /// INSTALLMODE_DEFAULT /// /// Provide the component and perform any installation necessary to provide the component. If the key file of a component in the /// requested feature, or a feature parent, is missing, reinstall the feature using MsiReinstallFeature with the following flag bits /// set: REINSTALLMODE_FILEMISSING, REINSTALLMODE_FILEOLDERVERSION, REINSTALLMODE_FILEVERIFY, REINSTALLMODE_MACHINEDATA, /// REINSTALLMODE_USERDATA and REINSTALLMODE_SHORTCUT. /// /// /// /// INSTALLMODE_EXISTING /// /// Provide the component only if the feature exists. Otherwise return ERROR_FILE_NOT_FOUND. This mode verifies that the key file of /// the component exists. /// /// /// /// INSTALLMODE_NODETECTION /// /// Provide the component only if the feature exists. Otherwise return ERROR_FILE_NOT_FOUND. This mode only checks that the /// component is registered and does not verify that the key file of the component exists. /// /// /// /// combination of the REINSTALLMODE flags /// /// Call MsiReinstallFeature to reinstall feature using this parameter for the dwReinstallMode parameter, and then provide the component. /// /// /// /// INSTALLMODE_NOSOURCERESOLUTION /// /// Provide the component only if the feature's installation state is INSTALLSTATE_LOCAL. If the feature's installation state is /// INSTALLSTATE_SOURCE, return ERROR_INSTALL_SOURCE_ABSENT. Otherwise return ERROR_FILE_NOT_FOUND. This mode only checks that the /// component is registered and does not verify that the key file exists. /// /// /// /// /// Pointer to a variable that receives the path to the component. This parameter can be null. /// /// /// Pointer to a variable that specifies the size, in characters, of the buffer pointed to by the lpPathBuf parameter. On input, /// this is the full size of the buffer, including a space for a terminating null character. If the buffer passed in is too small, /// the count returned does not include the terminating null character. /// /// If lpPathBuf is null, pcchBuf can be null. /// /// /// /// /// Value /// Meaning /// /// /// ERROR_BAD_CONFIGURATION /// The configuration data is corrupt. /// /// /// ERROR_FILE_NOT_FOUND /// The feature is absent or broken. this error is returned for dwInstallMode = INSTALLMODE_EXISTING. /// /// /// ERROR_INSTALL_FAILURE /// The installation failed. /// /// /// ERROR_INSTALL_NOTUSED /// The component being requested is disabled on the computer. /// /// /// ERROR_INVALID_PARAMETER /// An invalid parameter was passed to the function. /// /// /// ERROR_SUCCESS /// The function completed successfully. /// /// /// ERROR_UNKNOWN_FEATURE /// The feature ID does not identify a known feature. /// /// /// ERROR_UNKNOWN_PRODUCT /// The product code does not identify a known product. /// /// /// INSTALLSTATE_UNKNOWN /// An unrecognized product or a feature name was passed to the function. /// /// /// ERROR_MORE_DATA /// The buffer overflow is returned. /// /// /// ERROR_INSTALL_SOURCE_ABSENT /// Unable to detect a source. /// /// /// For more information, see Displayed Error Messages. /// /// /// /// Upon success of the MsiProvideComponent function, the pcchPathBuf parameter contains the length of the string in lpPathBuf. /// /// /// The MsiProvideComponent function combines the functionality of MsiUseFeature, MsiConfigureFeature, and /// MsiGetComponentPath. You can use the MsiProvideComponent function to simplify the calling sequence. However, because this /// function increments the usage count, use it with caution to prevent inaccurate usage counts. The MsiProvideComponent /// function also provides less flexibility than the series of individual calls. /// /// /// If the application is recovering from an unexpected situation, the application has probably already called MsiUseFeature and /// incremented the usage count. In this case, the application should call MsiConfigureFeature instead of MsiProvideComponent /// to avoid incrementing the count again. /// /// The INSTALLMODE_EXISTING option cannot be used in combination with the REINSTALLMODE flag. /// /// Features with components containing a corrupted file or the wrong version of a file must be explicitly reinstalled by the user /// or by having the application call MsiReinstallFeature. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msiprovidecomponenta UINT MsiProvideComponentA( LPCSTR szProduct, // LPCSTR szFeature, LPCSTR szComponent, DWORD dwInstallMode, LPSTR lpPathBuf, LPDWORD pcchPathBuf ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiProvideComponentA")] public static extern Win32Error MsiProvideComponent([MarshalAs(UnmanagedType.LPTStr)] string szProduct, [MarshalAs(UnmanagedType.LPTStr)] string szFeature, [MarshalAs(UnmanagedType.LPTStr)] string szComponent, INSTALLMODE dwInstallMode, [Out, Optional, MarshalAs(UnmanagedType.LPTStr)] StringBuilder lpPathBuf, [In, Optional] IntPtr pcchPathBuf); /// /// The MsiProvideQualifiedComponent function returns the full component path for a qualified component and performs any /// necessary installation. This function prompts for source if necessary, and increments the usage count for the feature. /// /// /// Specifies the component ID for the requested component. This may not be the GUID for the component itself, but rather a server /// that provides the correct functionality, as in the ComponentId column of the PublishComponent table. /// /// Specifies a qualifier into a list of advertising components (from PublishComponent Table). /// /// Defines the installation mode. This parameter can be one of the following values. /// /// /// Value /// Meaning /// /// /// INSTALLMODE_DEFAULT /// /// Provide the component and perform any installation necessary to provide the component. If the key file of a component in the /// requested feature, or a feature parent, is missing, reinstall the feature using MsiReinstallFeature with the following flag bits /// set: REINSTALLMODE_FILEMISSING, REINSTALLMODE_FILEOLDERVERSION, REINSTALLMODE_FILEVERIFY, REINSTALLMODE_MACHINEDATA, /// REINSTALLMODE_USERDATA, and REINSTALLMODE_SHORTCUT. /// /// /// /// INSTALLMODE_EXISTING /// /// Provide the component only if the feature exists. Otherwise return ERROR_FILE_NOT_FOUND. This mode verifies that the key file of /// the component exists. /// /// /// /// INSTALLMODE_NODETECTION /// /// Provide the component only if the feature exists. Otherwise return ERROR_FILE_NOT_FOUND. This mode only checks that the /// component is registered and does not verify that the key file of the component exists. /// /// /// /// combination of the REINSTALLMODE flags /// /// Call MsiReinstallFeature to reinstall the feature using this parameter for the dwReinstallMode parameter, and then provide the component. /// /// /// /// INSTALLMODE_NOSOURCERESOLUTION /// /// Provide the component only if the feature's installation state is INSTALLSTATE_LOCAL. If the feature's installation state is /// INSTALLSTATE_SOURCE, return ERROR_INSTALL_SOURCE_ABSENT. Otherwise, it returns ERROR_FILE_NOT_FOUND. This mode only checks that /// the component is registered and does not verify that the key file exists. /// /// /// /// /// Pointer to a variable that receives the path to the component. This parameter can be null. /// /// /// Pointer to a variable that specifies the size, in characters, of the buffer pointed to by the lpPathBuf parameter. On input, /// this is the full size of the buffer, including a space for a terminating null character. If the buffer passed in is too small, /// the count returned does not include the terminating null character. /// /// If lpPathBuf is null, pcchBuf can be null. /// /// /// /// /// Value /// Meaning /// /// /// ERROR_INDEX_ABSENT /// The component qualifier is invalid or absent. /// /// /// ERROR_SUCCESS /// The function completed successfully. /// /// /// ERROR_FILE_NOT_FOUND /// The feature is absent or broken. This error is returned for dwInstallMode = INSTALLMODE_EXISTING. /// /// /// ERROR_UNKNOWN_COMPONENT /// The specified component is unknown. /// /// /// An error relating to an action /// See Error Codes. /// /// /// Initialization Error /// An error relating to initialization occurred. /// /// /// /// /// /// Upon success of the MsiProvideQualifiedComponent function, the pcchPathBuf parameter contains the length of the string in lpPathBuf. /// /// /// Features with components containing a corrupted file or the wrong version of a file must be explicitly reinstalled by the user /// or by having the application call MsiReinstallFeature. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msiprovidequalifiedcomponenta UINT MsiProvideQualifiedComponentA( // LPCSTR szCategory, LPCSTR szQualifier, DWORD dwInstallMode, LPSTR lpPathBuf, LPDWORD pcchPathBuf ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiProvideQualifiedComponentA")] public static extern Win32Error MsiProvideQualifiedComponent([MarshalAs(UnmanagedType.LPTStr)] string szCategory, [MarshalAs(UnmanagedType.LPTStr)] string szQualifier, INSTALLMODE dwInstallMode, [Out, Optional, MarshalAs(UnmanagedType.LPTStr)] StringBuilder lpPathBuf, ref uint pcchPathBuf); /// /// The MsiProvideQualifiedComponent function returns the full component path for a qualified component and performs any /// necessary installation. This function prompts for source if necessary, and increments the usage count for the feature. /// /// /// Specifies the component ID for the requested component. This may not be the GUID for the component itself, but rather a server /// that provides the correct functionality, as in the ComponentId column of the PublishComponent table. /// /// Specifies a qualifier into a list of advertising components (from PublishComponent Table). /// /// Defines the installation mode. This parameter can be one of the following values. /// /// /// Value /// Meaning /// /// /// INSTALLMODE_DEFAULT /// /// Provide the component and perform any installation necessary to provide the component. If the key file of a component in the /// requested feature, or a feature parent, is missing, reinstall the feature using MsiReinstallFeature with the following flag bits /// set: REINSTALLMODE_FILEMISSING, REINSTALLMODE_FILEOLDERVERSION, REINSTALLMODE_FILEVERIFY, REINSTALLMODE_MACHINEDATA, /// REINSTALLMODE_USERDATA, and REINSTALLMODE_SHORTCUT. /// /// /// /// INSTALLMODE_EXISTING /// /// Provide the component only if the feature exists. Otherwise return ERROR_FILE_NOT_FOUND. This mode verifies that the key file of /// the component exists. /// /// /// /// INSTALLMODE_NODETECTION /// /// Provide the component only if the feature exists. Otherwise return ERROR_FILE_NOT_FOUND. This mode only checks that the /// component is registered and does not verify that the key file of the component exists. /// /// /// /// combination of the REINSTALLMODE flags /// /// Call MsiReinstallFeature to reinstall the feature using this parameter for the dwReinstallMode parameter, and then provide the component. /// /// /// /// INSTALLMODE_NOSOURCERESOLUTION /// /// Provide the component only if the feature's installation state is INSTALLSTATE_LOCAL. If the feature's installation state is /// INSTALLSTATE_SOURCE, return ERROR_INSTALL_SOURCE_ABSENT. Otherwise, it returns ERROR_FILE_NOT_FOUND. This mode only checks that /// the component is registered and does not verify that the key file exists. /// /// /// /// /// Pointer to a variable that receives the path to the component. This parameter can be null. /// /// /// Pointer to a variable that specifies the size, in characters, of the buffer pointed to by the lpPathBuf parameter. On input, /// this is the full size of the buffer, including a space for a terminating null character. If the buffer passed in is too small, /// the count returned does not include the terminating null character. /// /// If lpPathBuf is null, pcchBuf can be null. /// /// /// /// /// Value /// Meaning /// /// /// ERROR_INDEX_ABSENT /// The component qualifier is invalid or absent. /// /// /// ERROR_SUCCESS /// The function completed successfully. /// /// /// ERROR_FILE_NOT_FOUND /// The feature is absent or broken. This error is returned for dwInstallMode = INSTALLMODE_EXISTING. /// /// /// ERROR_UNKNOWN_COMPONENT /// The specified component is unknown. /// /// /// An error relating to an action /// See Error Codes. /// /// /// Initialization Error /// An error relating to initialization occurred. /// /// /// /// /// /// Upon success of the MsiProvideQualifiedComponent function, the pcchPathBuf parameter contains the length of the string in lpPathBuf. /// /// /// Features with components containing a corrupted file or the wrong version of a file must be explicitly reinstalled by the user /// or by having the application call MsiReinstallFeature. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msiprovidequalifiedcomponenta UINT MsiProvideQualifiedComponentA( // LPCSTR szCategory, LPCSTR szQualifier, DWORD dwInstallMode, LPSTR lpPathBuf, LPDWORD pcchPathBuf ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiProvideQualifiedComponentA")] public static extern Win32Error MsiProvideQualifiedComponent([MarshalAs(UnmanagedType.LPTStr)] string szCategory, [MarshalAs(UnmanagedType.LPTStr)] string szQualifier, INSTALLMODE dwInstallMode, [Out, Optional, MarshalAs(UnmanagedType.LPTStr)] StringBuilder lpPathBuf, [In, Optional] IntPtr pcchPathBuf); /// /// The MsiProvideQualifiedComponentEx function returns the full component path for a qualified component that is published /// by a product and performs any necessary installation. This function prompts for source if necessary and increments the usage /// count for the feature. /// /// /// Specifies the component ID that for the requested component. This may not be the GUID for the component itself but rather a /// server that provides the correct functionality, as in the ComponentId column of the PublishComponent table. /// /// Specifies a qualifier into a list of advertising components (from PublishComponent Table). /// /// Defines the installation mode. This parameter can be one of the following values. /// /// /// Value /// Meaning /// /// /// INSTALLMODE_DEFAULT /// /// Provide the component and perform any installation necessary to provide the component. If the key file of a component in the /// requested feature, or a feature parent, is missing, reinstall the feature using MsiReinstallFeature with the following flag bits /// set: REINSTALLMODE_FILEMISSING, REINSTALLMODE_FILEOLDERVERSION, REINSTALLMODE_FILEVERIFY, REINSTALLMODE_MACHINEDATA, /// REINSTALLMODE_USERDATA and REINSTALLMODE_SHORTCUT. /// /// /// /// INSTALLMODE_EXISTING /// /// Provide the component only if the feature exists. Otherwise return ERROR_FILE_NOT_FOUND. This mode verifies that the key file of /// the component exists. /// /// /// /// INSTALLMODE_NODETECTION /// /// Provide the component only if the feature exists. Otherwise return ERROR_FILE_NOT_FOUND. This mode only checks that the /// component is registered and does not verify that the key file of the component exists. /// /// /// /// INSTALLMODE_EXISTING /// Provide the component only if the feature exists, else return ERROR_FILE_NOT_FOUND. /// /// /// combination of the REINSTALLMODE flags /// /// Call MsiReinstallFeature to reinstall feature using this parameter for the dwReinstallMode parameter, and then provide the component. /// /// /// /// INSTALLMODE_NOSOURCERESOLUTION /// /// Provide the component only if the feature's installation state is INSTALLSTATE_LOCAL. If the feature's installation state is /// INSTALLSTATE_SOURCE, return ERROR_INSTALL_SOURCE_ABSENT. Otherwise return ERROR_FILE_NOT_FOUND. This mode only checks that the /// component is registered and does not verify that the key file exists. /// /// /// /// /// /// Specifies the product to match that has published the qualified component. If this is null, then this API works the same as MsiProvideQualifiedComponent. /// /// Reserved. Must be zero. /// Reserved. Must be zero. /// Pointer to a variable that receives the path to the component. This parameter can be null. /// /// /// Pointer to a variable that specifies the size, in characters, of the buffer pointed to by the lpPathBuf parameter. On input, /// this is the full size of the buffer, including a space for a terminating null character. If the buffer passed in is too small, /// the count returned does not include the terminating null character. /// /// If lpPathBuf is null, pcchBuf can be null. /// /// /// /// /// Value /// Meaning /// /// /// ERROR_INDEX_ABSENT /// Component qualifier invalid or not present. /// /// /// ERROR_SUCCESS /// The function completed successfully. /// /// /// ERROR_FILE_NOT_FOUND /// The feature is absent or broken. this error is returned for dwInstallMode = INSTALLMODE_EXISTING. /// /// /// ERROR_UNKNOWN_COMPONENT /// The specified component is unknown. /// /// /// An error relating to an action /// See Error Codes. /// /// /// Initialization Error /// An error relating to initialization occurred. /// /// /// /// /// /// Upon success of the MsiProvideQualifiedComponentEx function, the pcchPathBuf parameter contains the length of the string /// in lpPathBuf. /// /// /// Features with components containing a corrupted file or the wrong version of a file must be explicitly reinstalled by the user /// or by having the application call MsiReinstallFeature. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msiprovidequalifiedcomponentexa UINT // MsiProvideQualifiedComponentExA( LPCSTR szCategory, LPCSTR szQualifier, DWORD dwInstallMode, LPCSTR szProduct, DWORD dwUnused1, // DWORD dwUnused2, LPSTR lpPathBuf, LPDWORD pcchPathBuf ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiProvideQualifiedComponentExA")] public static extern Win32Error MsiProvideQualifiedComponentEx([MarshalAs(UnmanagedType.LPTStr)] string szCategory, [MarshalAs(UnmanagedType.LPTStr)] string szQualifier, INSTALLMODE dwInstallMode, [Optional, MarshalAs(UnmanagedType.LPTStr)] string szProduct, [Optional] uint dwUnused1, [Optional] uint dwUnused2, [Out, Optional, MarshalAs(UnmanagedType.LPTStr)] StringBuilder lpPathBuf, ref uint pcchPathBuf); /// /// The MsiProvideQualifiedComponentEx function returns the full component path for a qualified component that is published /// by a product and performs any necessary installation. This function prompts for source if necessary and increments the usage /// count for the feature. /// /// /// Specifies the component ID that for the requested component. This may not be the GUID for the component itself but rather a /// server that provides the correct functionality, as in the ComponentId column of the PublishComponent table. /// /// Specifies a qualifier into a list of advertising components (from PublishComponent Table). /// /// Defines the installation mode. This parameter can be one of the following values. /// /// /// Value /// Meaning /// /// /// INSTALLMODE_DEFAULT /// /// Provide the component and perform any installation necessary to provide the component. If the key file of a component in the /// requested feature, or a feature parent, is missing, reinstall the feature using MsiReinstallFeature with the following flag bits /// set: REINSTALLMODE_FILEMISSING, REINSTALLMODE_FILEOLDERVERSION, REINSTALLMODE_FILEVERIFY, REINSTALLMODE_MACHINEDATA, /// REINSTALLMODE_USERDATA and REINSTALLMODE_SHORTCUT. /// /// /// /// INSTALLMODE_EXISTING /// /// Provide the component only if the feature exists. Otherwise return ERROR_FILE_NOT_FOUND. This mode verifies that the key file of /// the component exists. /// /// /// /// INSTALLMODE_NODETECTION /// /// Provide the component only if the feature exists. Otherwise return ERROR_FILE_NOT_FOUND. This mode only checks that the /// component is registered and does not verify that the key file of the component exists. /// /// /// /// INSTALLMODE_EXISTING /// Provide the component only if the feature exists, else return ERROR_FILE_NOT_FOUND. /// /// /// combination of the REINSTALLMODE flags /// /// Call MsiReinstallFeature to reinstall feature using this parameter for the dwReinstallMode parameter, and then provide the component. /// /// /// /// INSTALLMODE_NOSOURCERESOLUTION /// /// Provide the component only if the feature's installation state is INSTALLSTATE_LOCAL. If the feature's installation state is /// INSTALLSTATE_SOURCE, return ERROR_INSTALL_SOURCE_ABSENT. Otherwise return ERROR_FILE_NOT_FOUND. This mode only checks that the /// component is registered and does not verify that the key file exists. /// /// /// /// /// /// Specifies the product to match that has published the qualified component. If this is null, then this API works the same as MsiProvideQualifiedComponent. /// /// Reserved. Must be zero. /// Reserved. Must be zero. /// Pointer to a variable that receives the path to the component. This parameter can be null. /// /// /// Pointer to a variable that specifies the size, in characters, of the buffer pointed to by the lpPathBuf parameter. On input, /// this is the full size of the buffer, including a space for a terminating null character. If the buffer passed in is too small, /// the count returned does not include the terminating null character. /// /// If lpPathBuf is null, pcchBuf can be null. /// /// /// /// /// Value /// Meaning /// /// /// ERROR_INDEX_ABSENT /// Component qualifier invalid or not present. /// /// /// ERROR_SUCCESS /// The function completed successfully. /// /// /// ERROR_FILE_NOT_FOUND /// The feature is absent or broken. this error is returned for dwInstallMode = INSTALLMODE_EXISTING. /// /// /// ERROR_UNKNOWN_COMPONENT /// The specified component is unknown. /// /// /// An error relating to an action /// See Error Codes. /// /// /// Initialization Error /// An error relating to initialization occurred. /// /// /// /// /// /// Upon success of the MsiProvideQualifiedComponentEx function, the pcchPathBuf parameter contains the length of the string /// in lpPathBuf. /// /// /// Features with components containing a corrupted file or the wrong version of a file must be explicitly reinstalled by the user /// or by having the application call MsiReinstallFeature. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msiprovidequalifiedcomponentexa UINT // MsiProvideQualifiedComponentExA( LPCSTR szCategory, LPCSTR szQualifier, DWORD dwInstallMode, LPCSTR szProduct, DWORD dwUnused1, // DWORD dwUnused2, LPSTR lpPathBuf, LPDWORD pcchPathBuf ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiProvideQualifiedComponentExA")] public static extern Win32Error MsiProvideQualifiedComponentEx([MarshalAs(UnmanagedType.LPTStr)] string szCategory, [MarshalAs(UnmanagedType.LPTStr)] string szQualifier, INSTALLMODE dwInstallMode, [Optional, MarshalAs(UnmanagedType.LPTStr)] string szProduct, [Optional] uint dwUnused1, [Optional] uint dwUnused2, [Out, Optional, MarshalAs(UnmanagedType.LPTStr)] StringBuilder lpPathBuf, [In, Optional] IntPtr pcchPathBuf); /// /// The MsiQueryComponentState function returns the installed state for a component. This function can query for a component /// of an instance of a product that is installed under user accounts other than the current user provided the product is not /// advertised under the per-user-unmanaged context for a user account other than the current user. The calling process must have /// administrative privileges to get information for a product installed for a user other than the current user. /// /// Specifies the ProductCode GUID for the product that contains the component. /// /// /// Specifies the security identifier (SID) of the account under which the instance of the product being queried exists. If /// dwContext is not MSIINSTALLCONTEXT_MACHINE, null specifies the current user. /// /// /// /// Type of SID /// Meaning /// /// /// NULL /// NULL denotes the currently logged on user. /// /// /// User SID /// Specifies enumeration for a particular user in the system. An example of user SID is "S-1-3-64-2415071341-1358098788-3127455600-2561". /// /// /// /// Note The special SID string "S-1-5-18" (system) cannot be used to enumerate products installed as per-machine. If /// dwContext is MSIINSTALLCONTEXT_MACHINE, szUserSid must be null. /// /// /// /// The installation context of the product instance being queried. /// /// /// Name /// Meaning /// /// /// MSIINSTALLCONTEXT_USERMANAGED /// Retrieves the component's state for the per–user–managed instance of the product. /// /// /// MSIINSTALLCONTEXT_USERUNMANAGED /// Retrieves the component's state for the per–user–non-managed instance of the product. /// /// /// MSIINSTALLCONTEXT_MACHINE /// Retrieves the component's state for the per-machine instance of the product. /// /// /// /// /// Specifies the component being queried. Component code GUID of the component as found in the ComponentID column of the Component table. /// /// /// /// Installation state of the component for the specified product instance. This parameter can return one of the following or null values. /// /// /// /// Value /// Meaning /// /// /// INSTALLSTATE_LOCAL /// The component is installed locally. /// /// /// INSTALLSTATE_SOURCE /// The component is installed to run from the source. /// /// /// /// /// The MsiQueryComponentState function returns the following values. /// /// /// Value /// Meaning /// /// /// ERROR_ACCESS_DENIED /// /// The calling process must have administrative privileges to get information for a product installed for a user other than the /// current user. /// /// /// /// ERROR_BAD_CONFIGURATION /// The configuration data is corrupt. /// /// /// ERROR_INVALID_PARAMETER /// An invalid parameter was passed to the function. /// /// /// ERROR_SUCCESS /// The function completed successfully. /// /// /// ERROR_UNKNOWN_COMPONENT /// The component ID does not identify a known component. /// /// /// ERROR_UNKNOWN_PRODUCT /// The product code does not identify a known product. /// /// /// ERROR_FUNCTION_FAILED /// Failures that cannot be ascribed to any Windows error code. /// /// /// ERROR_MORE_DATA /// Buffer too small to get the user SID. /// /// /// For more information, see Displayed Error Messages. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msiquerycomponentstatea UINT MsiQueryComponentStateA( LPCSTR // szProductCode, LPCSTR szUserSid, MSIINSTALLCONTEXT dwContext, LPCSTR szComponentCode, INSTALLSTATE *pdwState ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiQueryComponentStateA")] public static extern Win32Error MsiQueryComponentState([MarshalAs(UnmanagedType.LPTStr)] string szProductCode, [Optional, MarshalAs(UnmanagedType.LPTStr)] string szUserSid, MSIINSTALLCONTEXT dwContext, [MarshalAs(UnmanagedType.LPTStr)] string szComponentCode, out INSTALLSTATE pdwState); /// The MsiQueryFeatureState function returns the installed state for a product feature. /// Specifies the product code for the product that contains the feature of interest. /// Identifies the feature of interest. /// /// /// /// Value /// Meaning /// /// /// INSTALLSTATE_ABSENT /// The feature is not installed. /// /// /// INSTALLSTATE_ADVERTISED /// The feature is advertised /// /// /// INSTALLSTATE_LOCAL /// The feature is installed locally. /// /// /// INSTALLSTATE_SOURCE /// The feature is installed to run from source. /// /// /// INSTALLSTATE_INVALIDARG /// An invalid parameter was passed to the function. /// /// /// INSTALLSTATE_UNKNOWN /// The product code or feature ID is unknown. /// /// /// /// The MsiQueryFeatureState function does not validate that the feature is actually accessible. // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msiqueryfeaturestatea INSTALLSTATE MsiQueryFeatureStateA( LPCSTR // szProduct, LPCSTR szFeature ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiQueryFeatureStateA")] public static extern INSTALLSTATE MsiQueryFeatureState([MarshalAs(UnmanagedType.LPTStr)] string szProduct, [MarshalAs(UnmanagedType.LPTStr)] string szFeature); /// /// The MsiQueryFeatureStateEx function returns the installed state for a product feature. This function can be used to query /// any feature of an instance of a product installed under the machine account or any context under the current user account or the /// per-user-managed context under any user account other than the current user. A user must have administrative privileges to get /// information for a product installed for a user other than the current user. /// /// ProductCode GUID of the product that contains the feature of interest. /// /// /// Specifies the security identifier (SID) of the account, under which, the instance of the product being queried exists. If /// dwContext is not MSIINSTALLCONTEXT_MACHINE, a null value specifies the current user. /// /// /// /// Type of SID /// Meaning /// /// /// NULL /// NULL denotes the currently logged on user. /// /// /// User SID /// Specifies enumeration for a particular user in the system. An example of user SID is "S-1-3-64-2415071341-1358098788-3127455600-2561". /// /// /// /// Note The special SID string s-1-5-18 (system) cannot be used to enumerate features of products installed as per-machine. /// If dwContext is MSIINSTALLCONTEXT_MACHINE, szUserSid must be null. /// /// /// /// The installation context of the product instance being queried. /// /// /// Name /// Meaning /// /// /// MSIINSTALLCONTEXT_USERMANAGED /// Retrieves the feature state for the per-user-managed instance of the product. /// /// /// MSIINSTALLCONTEXT_USERUNMANAGED /// Retrieves the feature state for the per-user-unmanaged instance of the product. /// /// /// MSIINSTALLCONTEXT_MACHINE /// Retrieves the feature state for the per-machine instance of the product. /// /// /// /// /// Specifies the feature being queried. Identifier of the feature as found in the Feature column of the Feature table. /// /// /// /// Installation state of the feature for the specified product instance. This parameter can return one of the following or null. /// /// /// /// Value /// Meaning /// /// /// INSTALLSTATE_ADVERTISED /// This feature is advertised. /// /// /// INSTALLSTATE_LOCAL /// The feature is installed locally. /// /// /// INSTALLSTATE_SOURCE /// The feature is installed to run from source. /// /// /// /// /// The MsiQueryFeatureStateEx function returns the following values. /// /// /// Value /// Meaning /// /// /// ERROR_ACCESS_DENIED /// /// A user must have administrative privileges to get information for a product installed for a user other than the current user. /// /// /// /// ERROR_BAD_CONFIGURATION /// The configuration data is corrupt. /// /// /// ERROR_INVALID_PARAMETER /// An invalid parameter was passed to the function. /// /// /// ERROR_SUCCESS /// The function completed successfully. /// /// /// ERROR_UNKNOWN_FEATURE /// The feature ID does not identify a known feature. /// /// /// ERROR_UNKNOWN_PRODUCT /// The product code does not identify a known product. /// /// /// ERROR_FUNCTION_FAILED /// An unexpected internal failure. /// /// /// For more information, see Displayed Error Messages. /// /// /// The MsiQueryFeatureStateEx function does not validate that the feature is actually accessible. The /// MsiQueryFeatureStateEx function does not validate the feature ID. ERROR_UNKNOWN_FEATURE is returned for any /// unknown feature ID. When the query is made on a product installed under the per-user-unmanaged context for a user account other /// than the current user, the function fails. In this case the function returns ERROR_UNKNOWN_FEATURE, or if the product is /// advertised only (not installed), ERROR_UNKNOWN_PRODUCT is returned. /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msiqueryfeaturestateexa UINT MsiQueryFeatureStateExA( LPCSTR // szProductCode, LPCSTR szUserSid, MSIINSTALLCONTEXT dwContext, LPCSTR szFeature, INSTALLSTATE *pdwState ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiQueryFeatureStateExA")] public static extern Win32Error MsiQueryFeatureStateEx([MarshalAs(UnmanagedType.LPTStr)] string szProductCode, [Optional, MarshalAs(UnmanagedType.LPTStr)] string szUserSid, MSIINSTALLCONTEXT dwContext, [MarshalAs(UnmanagedType.LPTStr)] string szFeature, out INSTALLSTATE pdwState); /// The MsiQueryProductState function returns the installed state for a product. /// Specifies the product code that identifies the product to be queried. /// /// /// /// Value /// Meaning /// /// /// INSTALLSTATE_ABSENT /// The product is installed for a different user. /// /// /// INSTALLSTATE_ADVERTISED /// The product is advertised but not installed. /// /// /// INSTALLSTATE_DEFAULT /// The product is installed for the current user. /// /// /// INSTALLSTATE_INVALIDARG /// An invalid parameter was passed to the function. /// /// /// INSTALLSTATE_UNKNOWN /// The product is neither advertised or installed. /// /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msiqueryproductstatea INSTALLSTATE MsiQueryProductStateA( LPCSTR // szProduct ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiQueryProductStateA")] public static extern INSTALLSTATE MsiQueryProductState([MarshalAs(UnmanagedType.LPTStr)] string szProduct); /// The MsiReinstallFeature function reinstalls features. /// Specifies the product code for the product that contains the feature to be reinstalled. /// /// Specifies the feature to be reinstalled. The parent feature or child feature of the specified feature is not reinstalled. To /// reinstall the parent or child feature, you must call the MsiReinstallFeature function for each separately or use the /// MsiReinstallProduct function. /// /// /// Specifies what to install. This parameter can be one or more of the following values. /// /// /// Value /// Meaning /// /// /// REINSTALLMODE_FILEMISSING /// Reinstall only if the file is missing. /// /// /// REINSTALLMODE_FILEOLDERVERSION /// Reinstall if the file is missing or is an older version. /// /// /// REINSTALLMODE_FILEEQUALVERSION /// Reinstall if the file is missing, or is an equal or older version. /// /// /// REINSTALLMODE_FILEEXACT /// Reinstall if the file is missing or is a different version. /// /// /// REINSTALLMODE_FILEVERIFY /// /// Verify the checksum values, and reinstall the file if they are missing or corrupt. This flag only repairs files that have /// msidbFileAttributesChecksum in the Attributes column of the File table. /// /// /// /// REINSTALLMODE_FILEREPLACE /// Force all files to be reinstalled, regardless of checksum or version. /// /// /// REINSTALLMODE_USERDATA /// Rewrite all required registry entries from the Registry Table that go to theHKEY_CURRENT_USER or HKEY_USERS registry hive. /// /// /// REINSTALLMODE_MACHINEDATA /// /// Rewrite all required registry entries from the Registry Table that go to the HKEY_LOCAL_MACHINEor HKEY_CLASSES_ROOT registry /// hive. Rewrite all information from the Class Table, Verb Table, PublishComponent Table, ProgID Table, MIME Table, Icon Table, /// Extension Table, and AppID Table regardless of machine or user assignment. Reinstall all qualified components. When reinstalling /// an application, this option runs the RegisterTypeLibraries and InstallODBC actions. /// /// /// /// REINSTALLMODE_SHORTCUT /// Reinstall all shortcuts and re-cache all icons overwriting any existing shortcuts and icons. /// /// /// REINSTALLMODE_PACKAGE /// /// Use to run from the source package and re-cache the local package. Do not use for the first installation of an application or feature. /// /// /// /// /// /// /// /// Return code /// Description /// /// /// ERROR_INSTALL_FAILURE /// The installation failed. /// /// /// ERROR_INVALID_PARAMETER /// An invalid parameter was passed to the function. /// /// /// ERROR_INSTALL_SERVICE_FAILURE /// The installation service could not be accessed. /// /// /// ERROR_INSTALL_SUSPEND /// The installation was suspended and is incomplete. /// /// /// ERROR_INSTALL_USEREXIT /// The user canceled the installation. /// /// /// ERROR_SUCCESS /// The function completed successfully. /// /// /// ERROR_UNKNOWN_FEATURE /// The feature ID does not identify a known feature. /// /// /// ERROR_UNKNOWN_PRODUCT /// The product code does not identify a known product. /// /// /// For more information, see Displayed Error Messages. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msireinstallfeaturea UINT MsiReinstallFeatureA( LPCSTR szProduct, // LPCSTR szFeature, DWORD dwReinstallMode ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiReinstallFeatureA")] public static extern Win32Error MsiReinstallFeature([MarshalAs(UnmanagedType.LPTStr)] string szProduct, [MarshalAs(UnmanagedType.LPTStr)] string szFeature, REINSTALLMODE dwReinstallMode); /// The MsiReinstallProduct function reinstalls products. /// Specifies the product code for the product to be reinstalled. /// /// Specifies the reinstall mode. This parameter can be one or more of the following values. /// /// /// Value /// Meaning /// /// /// REINSTALLMODE_FILEMISSING /// Reinstall only if the file is missing. /// /// /// REINSTALLMODE_FILEOLDERVERSION /// Reinstall if the file is missing or is an older version. /// /// /// REINSTALLMODE_FILEEQUALVERSION /// Reinstall if the file is missing, or is an equal or older version. /// /// /// REINSTALLMODE_FILEEXACT /// Reinstall if the file is missing or is a different version. /// /// /// REINSTALLMODE_FILEVERIFY /// /// Verify the checksum values and reinstall the file if they are missing or corrupt. This flag only repairs files that have /// msidbFileAttributesChecksum in the Attributes column of the File table. /// /// /// /// REINSTALLMODE_FILEREPLACE /// Force all files to be reinstalled, regardless of checksum or version. /// /// /// REINSTALLMODE_USERDATA /// Rewrite all required registry entries from the Registry Table that go to theHKEY_CURRENT_USER or HKEY_USERS registry hive. /// /// /// REINSTALLMODE_MACHINEDATA /// /// Rewrite all required registry entries from the Registry Table that go to the HKEY_LOCAL_MACHINEor HKEY_CLASSES_ROOT registry /// hive. Rewrite all information from the Class Table, Verb Table, PublishComponent Table, ProgID Table, MIMET Table, Icon Table, /// Extension Table, and AppID Table regardless of machine or user assignment. Reinstall all qualified components. When reinstalling /// an application, this option runs the RegisterTypeLibraries and InstallODBC actions. /// /// /// /// REINSTALLMODE_SHORTCUT /// Reinstall all shortcuts and re-cache all icons overwriting any existing shortcuts and icons. /// /// /// REINSTALLMODE_PACKAGE /// /// Use to run from the source package and re-cache the local package. Do not use for the first installation of an application or feature. /// /// /// /// /// /// /// /// Return code /// Description /// /// /// ERROR_INSTALL_FAILURE /// The installation failed. /// /// /// ERROR_INVALID_PARAMETER /// An invalid parameter was passed to the function. /// /// /// ERROR_INSTALL_SERVICE_FAILURE /// The installation service could not be accessed. /// /// /// ERROR_INSTALL_SUSPEND /// The installation was suspended and is incomplete. /// /// /// ERROR_INSTALL_USEREXIT /// The user canceled the installation. /// /// /// ERROR_SUCCESS /// The function completed successfully. /// /// /// ERROR_UNKNOWN_PRODUCT /// The product code does not identify a known product. /// /// /// For more information, see Displayed Error Messages. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msireinstallproducta UINT MsiReinstallProductA( LPCSTR szProduct, // DWORD szReinstallMode ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiReinstallProductA")] public static extern Win32Error MsiReinstallProduct([MarshalAs(UnmanagedType.LPTStr)] string szProduct, REINSTALLMODE szReinstallMode); /// /// The MsiRemovePatches function removes one or more patches from a single product. To remove a patch from multiple /// products, MsiRemovePatches must be called for each product. /// /// /// A null-terminated string that represents the list of patches to remove. Each patch can be specified by the GUID of the patch or /// the full path to the patch package. The patches in the list are delimited by semicolons. /// /// /// A null-terminated string that is the ProductCode (GUID) of the product from which the patches are removed. This parameter cannot /// be NULL. /// /// /// Value that indicates the type of patch removal to perform. This parameter must be INSTALLTYPE_SINGLE_INSTANCE. /// /// /// Value /// Meaning /// /// /// INSTALLTYPE_SINGLE_INSTANCE /// The patch is uninstalled for only the product specified by szProduct. /// /// /// /// /// A null-terminated string that specifies command-line property settings. For more information see About Properties and Setting /// Public Property Values on the Command Line. This parameter can be NULL. /// /// /// The MsiRemovePatches function returns the following values. /// /// /// Value /// Meaning /// /// /// ERROR_INVALID_PARAMETER /// An invalid parameter was included. /// /// /// ERROR_PATCH_PACKAGE_OPEN_FAILED /// The patch package could not be opened. /// /// /// ERROR_SUCCESS /// The patch was successfully removed. /// /// /// ERROR_UNKNOWN_PRODUCT /// The product specified by szProductList is not installed either per-machine or per-user for the caller of MsiRemovePatches. /// /// /// ERROR_PATCH_PACKAGE_OPEN_FAILED /// The patch package could not be opened. /// /// /// ERROR_PATCH_PACKAGE_INVALID /// The patch package is invalid. /// /// /// ERROR_PATCH_PACKAGE_UNSUPPORTED /// The patch package cannot be processed by this version of the Windows Installer service. /// /// /// ERROR_PATCH_REMOVAL_UNSUPPORTED /// The patch package is not removable. /// /// /// ERROR_UNKNOWN_PATCH /// The patch has not been applied to this product. /// /// /// ERROR_PATCH_REMOVAL_DISALLOWED /// Patch removal was disallowed by policy. /// /// /// /// /// See Uninstalling Patches for an example that demonstrates how an application can remove a patch from all products that are /// available to the user. /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msiremovepatchesa UINT MsiRemovePatchesA( LPCSTR szPatchList, // LPCSTR szProductCode, INSTALLTYPE eUninstallType, LPCSTR szPropertyList ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiRemovePatchesA")] public static extern Win32Error MsiRemovePatches([MarshalAs(UnmanagedType.LPTStr)] string szPatchList, [MarshalAs(UnmanagedType.LPTStr)] string szProductCode, INSTALLTYPE eUninstallType, [Optional, MarshalAs(UnmanagedType.LPTStr)] string szPropertyList); /// /// The MsiSetExternalUI function enables an external user-interface handler. This external UI handler is called before the /// normal internal user-interface handler. The external UI handler has the option to suppress the internal UI by returning a /// non-zero value to indicate that it has handled the messages. For more information, see About the User Interface. /// /// Specifies a callback function that conforms to the INSTALLUI_HANDLER specification. /// /// /// Specifies which messages to handle using the external message handler. If the external handler returns a non-zero result, then /// that message will not be sent to the UI, instead the message will be logged if logging has been enabled. For more information, /// see the MsiEnableLog function. /// /// /// /// Value /// Meaning /// /// /// INSTALLLOGMODE_FILESINUSE /// Files in use information. When this message is received, a FilesInUse Dialog should be displayed. /// /// /// INSTALLLOGMODE_FATALEXIT /// Premature termination of installation. /// /// /// INSTALLLOGMODE_ERROR /// The error messages are logged. /// /// /// INSTALLLOGMODE_WARNING /// The warning messages are logged. /// /// /// INSTALLLOGMODE_USER /// The user requests are logged. /// /// /// INSTALLLOGMODE_INFO /// The status messages that are not displayed are logged. /// /// /// INSTALLLOGMODE_RESOLVESOURCE /// Request to determine a valid source location. /// /// /// INSTALLLOGMODE_RMFILESINUSE /// Files in use information. When this message is received, a MsiRMFilesInUse Dialog should be displayed. /// /// /// INSTALLLOGMODE_OUTOFDISKSPACE /// There was insufficient disk space. /// /// /// INSTALLLOGMODE_ACTIONSTART /// The start of new installation actions are logged. /// /// /// INSTALLLOGMODE_ACTIONDATA /// The data record with the installation action is logged. /// /// /// INSTALLLOGMODE_COMMONDATA /// The parameters for user-interface initialization are logged. /// /// /// INSTALLLOGMODE_PROGRESS /// /// Progress bar information. This message includes information on units so far and total number of units. For an explanation of the /// message format, see the MsiProcessMessage function. This message is only sent to an external user interface and is not logged. /// /// /// /// INSTALLLOGMODE_INITIALIZE /// /// If this is not a quiet installation, then the basic UI has been initialized. If this is a full UI installation, the full UI is /// not yet initialized. This message is only sent to an external user interface and is not logged. /// /// /// /// INSTALLLOGMODE_TERMINATE /// /// If a full UI is being used, the full UI has ended. If this is not a quiet installation, the basic UI has not yet ended. This /// message is only sent to an external user interface and is not logged. /// /// /// /// INSTALLLOGMODE_SHOWDIALOG /// Sent prior to display of the full UI dialog. This message is only sent to an external user interface and is not logged. /// /// /// INSTALLLOGMODE_INSTALLSTART /// Installation of product begins. The message contains the product's ProductName and ProductCode. /// /// /// INSTALLLOGMODE_INSTALLEND /// Installation of product ends. The message contains the product's ProductName, ProductCode, and return value. /// /// /// /// /// Pointer to an application context that is passed to the callback function. This parameter can be used for error checking. /// /// The return value is the previously set external handler, or zero (0) if there was no previously set handler. /// /// /// To restore the previous UI handler, second call is made to MsiSetExternalUI using the INSTALLUI_HANDLER returned by the /// first call to MsiSetExternalUI and specifying zero (0) for dwMessageFilter. /// /// /// The external user interface handler pointed to by the puiHandler parameter does not have full control over the external user /// interface unless MsiSetInternalUI is called with the dwUILevel parameter set to INSTALLUILEVEL_NONE. If MsiSetInternalUI /// is not called, the internal user interface level defaults to INSTALLUILEVEL_BASIC. As a result, any message not handled by the /// external user interface handler is handled by Windows Installer. The initial "Preparing to install. . ." dialog always appears /// even if the external user interface handler handles all messages. /// /// /// MsiSetExternalUI should only be called from a Bootstrapping application. You cannot call MsiSetExternalUI from a /// custom action. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msisetexternaluia INSTALLUI_HANDLERA MsiSetExternalUIA( // INSTALLUI_HANDLERA puiHandler, DWORD dwMessageFilter, LPVOID pvContext ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiSetExternalUIA")] public static extern INSTALLUI_HANDLER MsiSetExternalUI([Optional] INSTALLUI_HANDLER puiHandler, INSTALLLOGMODE dwMessageFilter, [In, Optional] IntPtr pvContext); /// The MsiSetExternalUIRecord function enables an external user-interface (UI) handler. /// /// Specifies a callback function that conforms to the INSTALLUI_HANDLER_RECORD specification. /// To disable the current external UI handler, call the function with this parameter set to a NULL value. /// /// /// /// Specifies which messages to handle using the external message handler. If the external handler returns a non-zero result, then /// that message is not sent to the UI, instead the message is logged if logging is enabled. For more information, see MsiEnableLog. /// /// /// /// Value /// Meaning /// /// /// INSTALLLOGMODE_FILESINUSE /// Files in use information. When this message is received, a FilesInUse Dialog should be displayed. /// /// /// INSTALLLOGMODE_FATALEXIT /// Premature termination of installation. /// /// /// INSTALLLOGMODE_ERROR /// The error messages are logged. /// /// /// INSTALLLOGMODE_WARNING /// The warning messages are logged. /// /// /// INSTALLLOGMODE_USER /// The user requests are logged. /// /// /// INSTALLLOGMODE_INFO /// The status messages that are not displayed are logged. /// /// /// INSTALLLOGMODE_RESOLVESOURCE /// Request to determine a valid source location. /// /// /// INSTALLLOGMODE_RMFILESINUSE /// Files in use information. When this message is received, a MsiRMFilesInUse Dialog should be displayed. /// /// /// INSTALLLOGMODE_OUTOFDISKSPACE /// The is insufficient disk space. /// /// /// INSTALLLOGMODE_ACTIONSTART /// The start of new installation actions are logged. /// /// /// INSTALLLOGMODE_ACTIONDATA /// The data record with the installation action is logged. /// /// /// INSTALLLOGMODE_COMMONDATA /// The parameters for user-interface initialization are logged. /// /// /// INSTALLLOGMODE_PROGRESS /// /// The Progress bar information. This message includes information about units so far and total number of units. This message is /// only sent to an external user interface and is not logged. For more information, see MsiProcessMessage. /// /// /// /// INSTALLLOGMODE_INITIALIZE /// /// If this is not a quiet installation, then the basic UI is initialized. If this is a full UI installation, the Full UI is not yet /// initialized. This message is only sent to an external user interface and is not logged. /// /// /// /// INSTALLLOGMODE_TERMINATE /// /// If a full UI is being used, the full UI has ended. If this is not a quiet installation, the basic UI has not ended. This message /// is only sent to an external user interface and is not logged. /// /// /// /// INSTALLLOGMODE_SHOWDIALOG /// Sent prior to display of the Full UI dialog. This message is only sent to an external user interface and is not logged. /// /// /// INSTALLLOGMODE_INSTALLSTART /// Installation of product begins. The message contains the product's ProductName and ProductCode. /// /// /// INSTALLLOGMODE_INSTALLEND /// Installation of product ends. The message contains the product's ProductName, ProductCode, and return value. /// /// /// /// /// A pointer to an application context that is passed to the callback function. /// This parameter can be used for error checking. /// /// /// Returns the pointer to the previously set callback function that conforms to the INSTALLUI_HANDLER_RECORD specification, or /// NULL if no callback is previously set. /// /// /// /// /// Return code /// Description /// /// /// ERROR_SUCCESS /// The function completes successfully. /// /// /// ERROR_CALL_NOT_IMPLEMENTED /// /// This value indicates that an attempt is made to call this function from a custom action. This function cannot be called from a /// custom action. /// /// /// /// /// /// This function cannot be called from Custom Actions. /// /// The external UI handler enabled by calling MsiSetExternalUIRecord receives messages in the format of a Record Object. The /// external UI handler enabled by calling MsiSetExternalUI receives messages in the format of a string. An external UI is always /// called before the Windows Installer internal UI. An enabled record-based external UI is called before any string-based external /// UI. If the record-based external UI handler returns 0 (zero), the message is sent to any enabled string-based external UI /// handler. If the external UI handler returns a non-zero value, the internal Windows Installer UI handler is suppressed and the /// messages are considered handled. /// /// /// This function stores the external user interfaces it has set. To replace the current external UI handler with a previous /// handler, call the function and specify the INSTALLUI_HANDLER_RECORD as the puiHandler parameter and 0 (zero) as the /// dwMessageFilter parameter. /// /// /// The external user interface handler pointed to by the puiHandler parameter does not have full control over the external user /// interface unless MsiSetInternalUI is called with the dwUILevel parameter set to INSTALLUILEVEL_NONE. If MsiSetInternalUI /// is not called, the internal user interface level defaults to INSTALLUILEVEL_BASIC. As a result, any message not handled by the /// external user interface handler is handled by Windows Installer. The initial "Preparing to install. . ." dialog always appears /// even if the external user interface handler handles all messages. MsiSetExternalUI should only be called from an Bootstrapping /// application. You cannot call MsiSetExternalUI from a custom action. /// /// To disable this external UI handler, call MsiSetExternalUIRecord with a NULL value for the puiHandler parameter. /// /// Windows Installer 2.0 and Windows Installer 3.0: Not supported. The MsiSetExternalUIRecord function is available /// beginning with Windows Installer 3.1. /// /// For more information about using a record-based external handler, see Monitoring an Installation Using MsiSetExternalUIRecord. /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msisetexternaluirecord UINT MsiSetExternalUIRecord( // INSTALLUI_HANDLER_RECORD puiHandler, DWORD dwMessageFilter, LPVOID pvContext, PINSTALLUI_HANDLER_RECORD ppuiPrevHandler ); [DllImport(Lib_Msi, SetLastError = false, ExactSpelling = true)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiSetExternalUIRecord")] public static extern Win32Error MsiSetExternalUIRecord([Optional] INSTALLUI_HANDLER_RECORD puiHandler, INSTALLLOGMODE dwMessageFilter, [In, Optional] IntPtr pvContext, out INSTALLUI_HANDLER_RECORD ppuiPrevHandler); /// /// The MsiSetInternalUI function enables the installer's internal user interface. Then this user interface is used for all /// subsequent calls to user-interface-generating installer functions in this process. For more information, see User Interface Levels. /// /// /// Specifies the level of complexity of the user interface. This parameter can be one of the following values. /// /// /// Value /// Meaning /// /// /// INSTALLUILEVEL_FULL /// Authored user interface with wizards, progress, and errors. /// /// /// INSTALLUILEVEL_REDUCED /// Authored user interface with wizard dialog boxes suppressed. /// /// /// INSTALLUILEVEL_BASIC /// Simple progress and error handling. /// /// /// INSTALLUILEVEL_DEFAULT /// The installer chooses an appropriate user interface level. /// /// /// INSTALLUILEVEL_NONE /// Completely silent installation. /// /// /// INSTALLUILEVEL_ENDDIALOG /// /// If combined with any above value, the installer displays a modal dialog box at the end of a successful installation or if there /// has been an error. No dialog box is displayed if the user cancels. /// /// /// /// INSTALLUILEVEL_PROGRESSONLY /// /// If combined with the INSTALLUILEVEL_BASIC value, the installer shows simple progress dialog boxes but does not display any modal /// dialog boxes or error dialog boxes. /// /// /// /// INSTALLUILEVEL_NOCHANGE /// No change in the UI level. However, if phWnd is not Null, the parent window can change. /// /// /// INSTALLUILEVEL_HIDECANCEL /// /// If combined with the INSTALLUILEVEL_BASIC value, the installer shows simple progress dialog boxes but does not display a Cancel /// button on the dialog. This prevents users from canceling the install. /// /// /// /// INSTALLUILEVEL_SOURCERESONLY /// /// If this value is combined with the INSTALLUILEVEL_NONE value, the installer displays only the dialog boxes used for source /// resolution. No other dialog boxes are shown. This value has no effect if the UI level is not INSTALLUILEVEL_NONE. It is used /// with an external user interface designed to handle all of the UI except for source resolution. In this case, the installer /// handles source resolution. /// /// /// /// /// /// Pointer to a window. This window becomes the owner of any user interface created. A pointer to the previous owner of the user /// interface is returned. If this parameter is null, the owner of the user interface does not change. /// /// /// The previous user interface level is returned. If an invalid dwUILevel is passed, then INSTALLUILEVEL_NOCHANGE is returned. /// /// /// /// The MsiSetInternalUI function is useful when the installer must display a user interface. For example, if a feature is /// installed, but the source is a compact disc that must be inserted, the installer prompts the user for the compact disc. /// Depending on the nature of the installation, the application might also display progress indicators or query the user for information. /// /// /// When Msi.dll is loaded, the user interface level is set to DEFAULT and the user interface owner is set to 0 (that is, the /// initial user interface owner is the desktop). /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msisetinternalui INSTALLUILEVEL MsiSetInternalUI( INSTALLUILEVEL // dwUILevel, HWND *phWnd ); [DllImport(Lib_Msi, SetLastError = false, ExactSpelling = true)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiSetInternalUI")] public static extern INSTALLUILEVEL MsiSetInternalUI(INSTALLUILEVEL dwUILevel, ref HWND phWnd); /// /// The MsiSetInternalUI function enables the installer's internal user interface. Then this user interface is used for all /// subsequent calls to user-interface-generating installer functions in this process. For more information, see User Interface Levels. /// /// /// Specifies the level of complexity of the user interface. This parameter can be one of the following values. /// /// /// Value /// Meaning /// /// /// INSTALLUILEVEL_FULL /// Authored user interface with wizards, progress, and errors. /// /// /// INSTALLUILEVEL_REDUCED /// Authored user interface with wizard dialog boxes suppressed. /// /// /// INSTALLUILEVEL_BASIC /// Simple progress and error handling. /// /// /// INSTALLUILEVEL_DEFAULT /// The installer chooses an appropriate user interface level. /// /// /// INSTALLUILEVEL_NONE /// Completely silent installation. /// /// /// INSTALLUILEVEL_ENDDIALOG /// /// If combined with any above value, the installer displays a modal dialog box at the end of a successful installation or if there /// has been an error. No dialog box is displayed if the user cancels. /// /// /// /// INSTALLUILEVEL_PROGRESSONLY /// /// If combined with the INSTALLUILEVEL_BASIC value, the installer shows simple progress dialog boxes but does not display any modal /// dialog boxes or error dialog boxes. /// /// /// /// INSTALLUILEVEL_NOCHANGE /// No change in the UI level. However, if phWnd is not Null, the parent window can change. /// /// /// INSTALLUILEVEL_HIDECANCEL /// /// If combined with the INSTALLUILEVEL_BASIC value, the installer shows simple progress dialog boxes but does not display a Cancel /// button on the dialog. This prevents users from canceling the install. /// /// /// /// INSTALLUILEVEL_SOURCERESONLY /// /// If this value is combined with the INSTALLUILEVEL_NONE value, the installer displays only the dialog boxes used for source /// resolution. No other dialog boxes are shown. This value has no effect if the UI level is not INSTALLUILEVEL_NONE. It is used /// with an external user interface designed to handle all of the UI except for source resolution. In this case, the installer /// handles source resolution. /// /// /// /// /// /// Pointer to a window. This window becomes the owner of any user interface created. A pointer to the previous owner of the user /// interface is returned. If this parameter is null, the owner of the user interface does not change. /// /// /// The previous user interface level is returned. If an invalid dwUILevel is passed, then INSTALLUILEVEL_NOCHANGE is returned. /// /// /// /// The MsiSetInternalUI function is useful when the installer must display a user interface. For example, if a feature is /// installed, but the source is a compact disc that must be inserted, the installer prompts the user for the compact disc. /// Depending on the nature of the installation, the application might also display progress indicators or query the user for information. /// /// /// When Msi.dll is loaded, the user interface level is set to DEFAULT and the user interface owner is set to 0 (that is, the /// initial user interface owner is the desktop). /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msisetinternalui INSTALLUILEVEL MsiSetInternalUI( INSTALLUILEVEL // dwUILevel, HWND *phWnd ); [DllImport(Lib_Msi, SetLastError = false, ExactSpelling = true)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiSetInternalUI")] public static extern INSTALLUILEVEL MsiSetInternalUI(INSTALLUILEVEL dwUILevel, [In, Optional] IntPtr phWnd); /// /// The MsiSourceListAddMediaDisk function adds or updates a disk of the media source of a registered product or patch. If /// the disk specified already exists, it is updated with the new values. If the disk specified does not exist, a new disk entry is /// created with the new values. /// /// /// The ProductCode or patch GUID of the product or patch. Use a null-terminated string. If the string is longer than 39 characters, /// the function fails and returns ERROR_INVALID_PARAMETER. This parameter cannot be NULL. /// /// /// /// This parameter can be a string SID that specifies the user account that contains the product or patch. The SID is not validated /// or resolved. An incorrect SID can return ERROR_UNKNOWN_PRODUCT or ERROR_UNKNOWN_PATCH. /// /// /// /// Type of SID /// Meaning /// /// /// NULL /// /// NULL denotes the currently logged on user. When referencing the current user account, szUserSID can be NULL and dwContext can be /// MSIINSTALLCONTEXT_USERMANAGED or MSIINSTALLCONTEXT_USERUNMANAGED. /// /// /// /// User SID /// Specifies enumeration for a particular user in the system. An example of user SID is "S-1-3-64-2415071341-1358098788-3127455600-2561". /// /// /// /// Note The special SID string s-1-5-18 (system) cannot be used to enumerate products or patches installed as per-machine. /// Setting the SID value to s-1-5-18 returns ERROR_INVALID_PARAMETER. When dwContext is set to MSIINSTALLCONTEXT_MACHINE only, /// szUserSid must be NULL. /// /// /// Note The special SID string s-1-1-0 (everyone) should not be used. Setting the SID value to s-1-1-0 fails and returns /// ERROR_INVALID_PARAM . /// /// /// /// /// This parameter specifies the context of the product or patch instance. This parameter can contain one of the following values. /// /// /// /// Type of context /// Meaning /// /// /// MSIINSTALLCONTEXT_USERMANAGED /// The product or patch instance exists in the per-user-managed context. /// /// /// MSIINSTALLCONTEXT_USERUNMANAGED /// The product or patch instance exists in the per-user-unmanaged context. /// /// /// MSIINSTALLCONTEXT_MACHINE /// The product or patch instance exists in the per-machine context. /// /// /// /// /// The dwOptions value specifies the meaning of szProductCodeOrPatchCode. /// /// /// Flag /// Meaning /// /// /// MSICODE_PRODUCT /// szProductCodeOrPatchCode is a product code GUID. /// /// /// MSICODE_PATCH /// szProductCodeOrPatchCode is a patch code GUID. /// /// /// /// This parameter provides the ID of the disk being added or updated. /// /// The szVolumeLabel provides the label of the disk being added or updated. An update overwrites the existing volume label in the /// registry. To change the disk prompt only, get the existing volume label from the registry and provide it in this call along with /// the new disk prompt. Passing a NULL or empty string for szVolumeLabel registers an empty string (0 bytes in length) as /// the volume label. /// /// /// On entry to MsiSourceListAddMediaDisk, szDiskPrompt provides the disk prompt of the disk being added or updated. An /// update overwrites the registered disk prompt. To change the volume label only, get the existing disk prompt that is registered /// and provide it when calling MsiSourceListAddMediaDisk along with the new volume label. Passing NULL or an empty /// string registers an empty string (0 bytes in length) as the disk prompt. /// /// /// The MsiSourceListAddMediaDisk function returns the following values. /// /// /// Value /// Meaning /// /// /// ERROR_ACCESS_DENIED /// /// The user does not have the ability to read the specified media source or the specified product or patch. This does not indicate /// whether a media source, product or patch was found. /// /// /// /// ERROR_BAD_CONFIGURATION /// The configuration data is corrupt. /// /// /// ERROR_INSTALL_SERVICE_FAILURE /// The Windows Installer service could not be accessed. /// /// /// ERROR_INVALID_PARAMETER /// An invalid parameter was passed to the function. /// /// /// ERROR_SUCCESS /// The value was successfully reordered. /// /// /// ERROR_UNKNOWN_PATCH /// The patch was not found. /// /// /// ERROR_UNKNOWN_PRODUCT /// The product was not found. /// /// /// ERROR_FUNCTION_FAILED /// Unexpected internal failure. /// /// /// /// /// /// Administrators can modify the installation of a product or patch instance that exists under the machine context or under their /// own per-user context (managed or unmanaged.) They can modify the installation of a product or patch instance that exists under /// any user's per-user-managed context. Administrators cannot modify another user's installation of a product or patch instance /// that exists under that other user's per-user-unmanaged context. /// /// /// Non-administrators cannot modify the installation of a product or patch instance that exists under another user's per-user /// context (managed or unmanaged.) They can modify the installation of a product or patch instance that exists under their own /// per-user-unmanaged context. They can modify the installation of a product or patch instance under the machine context or their /// own per-user-managed context only if they are enabled to browse for a product or patch source. Users can be enabled to browse /// for sources by setting policy. For more information, see DisableBrowse, AllowLockdownBrowse, AllowLockDownMedia and /// AlwaysInstallElevated policies. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msisourcelistaddmediadiska UINT MsiSourceListAddMediaDiskA( LPCSTR // szProductCodeOrPatchCode, LPCSTR szUserSid, MSIINSTALLCONTEXT dwContext, DWORD dwOptions, DWORD dwDiskId, LPCSTR szVolumeLabel, // LPCSTR szDiskPrompt ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiSourceListAddMediaDiskA")] public static extern Win32Error MsiSourceListAddMediaDisk([MarshalAs(UnmanagedType.LPTStr)] string szProductCodeOrPatchCode, [Optional, MarshalAs(UnmanagedType.LPTStr)] string szUserSid, MSIINSTALLCONTEXT dwContext, MSICODE dwOptions, uint dwDiskId, [Optional, MarshalAs(UnmanagedType.LPTStr)] string szVolumeLabel, [Optional, MarshalAs(UnmanagedType.LPTStr)] string szDiskPrompt); /// /// /// The MsiSourceListAddSource function adds to the list of valid network sources that contain the specified type of sources /// for a product or patch in a specified user context. /// /// The number of sources in the SOURCELIST property is unlimited. /// /// The ProductCode of the product to modify. /// /// /// The user name for a per-user installation. On Windows 2000 or Windows XP, the user name should always be in the format of /// DOMAIN\USERNAME (or MACHINENAME\USERNAME for a local user). /// /// An empty string or NULL for a per-machine installation. /// /// Reserved for future use. This value must be set to 0. /// Pointer to the string specifying the source. /// /// /// /// Return code /// Description /// /// /// ERROR_ACCESS_DENIED /// The user does not have the ability to add a source. /// /// /// ERROR_BAD_CONFIGURATION /// The configuration data is corrupt. /// /// /// ERROR_BAD_USERNAME /// Could not resolve the user name. /// /// /// ERROR_FUNCTION_FAILED /// The function did not succeed. /// /// /// ERROR_INSTALL_SERVICE_FAILURE /// Could not access installer service. /// /// /// ERROR_INVALID_PARAMETER /// An invalid parameter was passed to the function. /// /// /// ERROR_SUCCESS /// The source was added. /// /// /// ERROR_UNKNOWN_PRODUCT /// The specified product is unknown. /// /// /// /// /// /// An administrator can modify per-machine installations, their own per-user non-managed installations, and the per-user managed /// installations for any user. A non-administrator can only modify per-machine installations and their own (managed or /// non-managed)per-user installations. Users can be enabled to browse for sources by setting policy. For more information, see the /// DisableBrowse, AllowLockdownBrowse, and AlwaysInstallElevated policies. /// /// /// Note that this function merely adds the new source to the list of valid sources. If another source was used to install the /// product, the new source is not used until the current source is unavailable. /// /// It is the responsibility of the caller to ensure that the provided source is a valid source image for the product. /// /// If the user name is an empty string or NULL, the function operates on the per-machine installation of the product. In /// this case, if the product is installed only in the per-user state, the function returns ERROR_UNKNOWN_PRODUCT. /// /// /// If the user name is not an empty string or NULL, it specifies the name of the user whose product installation is /// modified. If the user name is the current user name, the function first attempts to modify a non-managed installation of the /// product. If no non-managed installation of the product can be found, the function then tries to modify a managed per-user /// installation of the product. If no managed or unmanaged per-user installations of the product can be found, the function returns /// ERROR_UNKNOWN_PRODUCT, even if the product is installed per-machine. /// /// /// This function can not modify a non-managed installation for any user besides the current user. If the user name is not an empty /// string or NULL, but is not the current user, the function only checks for a managed per-user installation of the product /// for the specified user. If the product is not installed as managed per-user for the specified user, the function returns /// ERROR_UNKNOWN_PRODUCT, even if the product is installed per-machine. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msisourcelistaddsourcea UINT MsiSourceListAddSourceA( LPCSTR // szProduct, LPCSTR szUserName, DWORD dwReserved, LPCSTR szSource ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiSourceListAddSourceA")] public static extern Win32Error MsiSourceListAddSource([MarshalAs(UnmanagedType.LPTStr)] string szProduct, [Optional, MarshalAs(UnmanagedType.LPTStr)] string szUserName, [Optional] uint dwReserved, [MarshalAs(UnmanagedType.LPTStr)] string szSource); /// /// The MsiSourceListAddSourceEx function adds or reorders the set of sources of a patch or product in a specified context. /// It can also create a source list for a patch that does not exist in the specified context. /// /// /// The ProductCode or patch GUID of the product or patch. Use a null-terminated string. If the string is longer than 39 characters, /// the function fails and returns ERROR_INVALID_PARAMETER. This parameter cannot be NULL. /// /// /// /// This parameter can be a string SID that specifies the user account that contains the product or patch. The SID is not validated /// or resolved. An incorrect SID can return ERROR_UNKNOWN_PRODUCT or ERROR_UNKNOWN_PATCH. When referencing a machine /// context, szUserSID must be NULL and dwContext must be MSIINSTALLCONTEXT_MACHINE. /// /// /// /// Type of SID /// Meaning /// /// /// NULL /// /// NULL denotes the currently logged on user. When referencing the current user account, szUserSID can be NULL and dwContext can be /// MSIINSTALLCONTEXT_USERMANAGED or MSIINSTALLCONTEXT_USERUNMANAGED. /// /// /// /// User SID /// Specifies enumeration for a particular user in the system. An example of a user SID is "S-1-3-64-2415071341-1358098788-3127455600-2561". /// /// /// /// Note The special SID string s-1-5-18 (system) cannot be used to enumerate products or patches installed as per-machine. /// Setting the SID value to "S-1-5-18" returns ERROR_INVALID_PARAMETER. /// /// /// Note The special SID string s-1-1-0 (everyone) should not be used. Setting the SID value to "S-1-1-0" fails and returns ERROR_INVALID_PARAM. /// /// /// /// /// This parameter specifies the context of the product or patch instance. This parameter can contain one of the following values. /// /// /// /// Type of context /// Meaning /// /// /// MSIINSTALLCONTEXT_USERMANAGED /// The product or patch instance exists in the per-user-managed context. /// /// /// MSIINSTALLCONTEXT_USERUNMANAGED /// The product or patch instance exists in the per-user-unmanaged context. /// /// /// MSIINSTALLCONTEXT_MACHINE /// The product or patch instance exists in the per-machine context. /// /// /// /// /// /// The dwOptions value determines the interpretation of the szProductCodeOrPatchCode value and the type of sources to clear. This /// parameter must be a combination of one of the following MSISOURCETYPE_ constants and one of the following MSICODE_ constants. /// /// /// /// Flag /// Meaning /// /// /// MSISOURCETYPE_NETWORK /// The source is a network type. /// /// /// MSISOURCETYPE_URL /// The source is a URL type. /// /// /// MSICODE_PRODUCT /// szProductCodeOrPatchCode is a product code. /// /// /// MSICODE_PATCH /// szProductCodeOrPatchCode is a patch code. /// /// /// /// /// Source to add or move. This parameter is expected to contain only the path without the filename. The filename is already /// registered as "PackageName" and can be manipulated through MsiSourceListSetInfo. This argument is required. /// /// /// /// This parameter provides the new index for the source. All sources are indexed in the source list from 1 to N, where N is the /// count of sources in the list. Every source in the list has a unique index. /// /// /// If MsiSourceListAddSourceEx is called with a new source and dwIndex set to 0 (zero), the new source is appended to the /// existing list. If dwIndex is set to 0 and the source already exists in the list, no update is done on the list. /// /// /// If MsiSourceListAddSourceEx is called with a new source and dwIndex set to a non-zero value less than count (N), the new /// source is placed at the specified index and the other sources are re-indexed. If the source already exists, it is moved to the /// specified index and the other sources are re-indexed. /// /// /// If MsiSourceListAddSourceEx is called with a new source and dwIndex set to a non-zero value greater than the count of /// sources (N), the new source is appended to the existing list. If the source already exists, it is moved to the end of the list /// and the other sources are re-indexed. /// /// /// /// The MsiSourceListAddSourceEx function returns the following values. /// /// /// Value /// Meaning /// /// /// ERROR_ACCESS_DENIED /// The user does not have the ability to add or move a source. Does not indicate whether the product or patch was found. /// /// /// ERROR_BAD_CONFIGURATION /// The configuration data is corrupt. /// /// /// ERROR_INSTALL_SERVICE_FAILURE /// Could not access the Windows Installer service. /// /// /// ERROR_SUCCESS /// The source was inserted or updated. /// /// /// ERROR_UNKNOWN_PRODUCT /// The specified product is unknown. /// /// /// ERROR_UNKNOWN_PATCH /// The specified patch is unknown. /// /// /// ERROR_FUNCTION_FAILED /// Unexpected internal failure. /// /// /// /// /// /// Administrators can modify the installation of a product or patch instance that exists under the machine context or under their /// own per-user context (managed or unmanaged.) They can modify the installation of a product or patch instance that exists under /// any user's per-user-managed context. Administrators cannot modify another user's installation of a product or patch instance /// that exists under that other user's per-user-unmanaged context. /// /// /// Non-administrators cannot modify the installation of a product or patch instance that exists under another user's per-user /// context (managed or unmanaged.) They can modify the installation of a product or patch instance that exists under their own /// per-user-unmanaged context. They can modify the installation of a product or patch instance under the machine context or their /// own per-user-managed context only if they are enabled to browse for a product or patch source. Users can be enabled to browse /// for sources by setting policy. For more information, see the DisableBrowse, AllowLockdownBrowse, and AlwaysInstallElevated policies. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msisourcelistaddsourceexa UINT MsiSourceListAddSourceExA( LPCSTR // szProductCodeOrPatchCode, LPCSTR szUserSid, MSIINSTALLCONTEXT dwContext, DWORD dwOptions, LPCSTR szSource, DWORD dwIndex ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiSourceListAddSourceExA")] public static extern Win32Error MsiSourceListAddSourceEx([MarshalAs(UnmanagedType.LPTStr)] string szProductCodeOrPatchCode, [Optional, MarshalAs(UnmanagedType.LPTStr)] string szUserSid, MSIINSTALLCONTEXT dwContext, uint dwOptions, [MarshalAs(UnmanagedType.LPTStr)] string szSource, uint dwIndex); /// /// The MsiSourceListClearAll function removes all network sources from the source list of a patch or product in a specified /// context. For more information, see Source Resiliency. /// /// The ProductCode of the product to modify. /// /// /// The user name for a per-user installation. The user name should always be in the format of DOMAIN\USERNAME (or /// MACHINENAME\USERNAME for a local user). /// /// An empty string or NULL for a per-machine installation. /// /// Reserved for future use. This value must be set to 0. /// /// The MsiSourceListClearAll function returns the following values. /// /// /// Value /// Meaning /// /// /// ERROR_ACCESS_DENIED /// The user does not have the ability to clear the source list for this product. /// /// /// ERROR_BAD_CONFIGURATION /// The configuration data is corrupt. /// /// /// ERROR_BAD_USERNAME /// Could not resolve the user name. /// /// /// ERROR_FUNCTION_FAILED /// The function did not succeed. /// /// /// ERROR_INSTALL_SERVICE_FAILURE /// Could not access installer service. /// /// /// ERROR_INVALID_PARAMETER /// An invalid parameter was passed to the function. /// /// /// ERROR_SUCCESS /// The function succeeded. /// /// /// ERROR_UNKNOWN_PRODUCT /// The specified product is unknown. /// /// /// /// /// /// An administrator can modify per-machine installations, their own per-user non-managed installations, and the per-user managed /// installations for any user. A non-administrator can only modify per-machine installations and their own (managed or /// non-managed)per-user installations. Users can be enabled to browse for sources by setting policy. For more information, see the /// DisableBrowse, AllowLockdownBrowse, and AlwaysInstallElevated policies. /// /// /// If a network source is the current source for the product, this function forces the installer to search the source list for a /// valid source the next time a source is needed. If the current source is media or a URL source, it is still valid after this call /// and the source list is not searched unless MsiSourceListForceResolution is also called. /// /// /// If the user name is an empty string or NULL, the function operates on the per-machine installation of the product. In /// this case, if the product is installed as per-user only, the function returns ERROR_UNKNOWN_PRODUCT. /// /// /// If the user name is not an empty string or NULL, it specifies the name of the user whose product installation is /// modified. If the user name is the current user name, the function first attempts to modify a non-managed installation of the /// product. If no non-managed installation of the product can be found, the function then tries to modify a managed per-user /// installation of the product. If no managed or unmanaged per-user installations of the product can be found, the function returns /// ERROR_UNKNOWN_PRODUCT, even if the product is installed per-machine. /// /// /// This function cannot modify a non-managed installation for any user besides the current user. If the user name is not an empty /// string or NULL, but is not the current user, the function only checks for a managed per-user installation of the product /// for the specified user. If the product is not installed as managed per-user for the specified user, the function returns /// ERROR_UNKNOWN_PRODUCT, even if the product is installed per-machine. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msisourcelistclearalla UINT MsiSourceListClearAllA( LPCSTR // szProduct, LPCSTR szUserName, DWORD dwReserved ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiSourceListClearAllA")] public static extern Win32Error MsiSourceListClearAll([MarshalAs(UnmanagedType.LPTStr)] string szProduct, [Optional, MarshalAs(UnmanagedType.LPTStr)] string szUserName, uint dwReserved = 0); /// /// The MsiSourceListClearAllEx function removes all the existing sources of a given source type for the specified product or /// patch instance. The patch registration is also removed if the sole source of the patch gets removed and if the patch is not /// installed as a new patch by any client in the same context. Specifying that MsiSourceListClearAllEx remove the current /// source for this product or patch forces the installer to search the source list for a source the next time a source is required. /// /// /// The ProductCode or patch GUID of the product or patch. Use a null-terminated string. If the string is longer than 39 characters, /// the function fails and returns ERROR_INVALID_PARAMETER. This parameter cannot be NULL. /// /// /// This parameter can be a string SID that specifies the user account that contains the product or patch. The SID is not validated /// or resolved. An incorrect SID can return ERROR_UNKNOWN_PRODUCT or ERROR_UNKNOWN_PATCH. When referencing a machine context, /// szUserSID must be NULL and dwContext must be MSIINSTALLCONTEXT_MACHINE. Using the machine SID ("S-1-5-18") returns /// ERROR_INVALID PARAMETER. When referencing the current user account, szUserSID can be NULL and dwContext can be /// MSIINSTALLCONTEXT_USERMANAGED or MSIINSTALLCONTEXT_USERUNMANAGED. /// /// /// /// This parameter specifies the context of the product or patch instance. This parameter can contain one of the following values. /// /// /// /// Type of context /// Meaning /// /// /// MSIINSTALLCONTEXT_USERMANAGED /// The product or patch instance exists in the per-user-managed context. /// /// /// MSIINSTALLCONTEXT_USERUNMANAGED /// The product or patch instance exists in the per-user-unmanaged context. /// /// /// MSIINSTALLCONTEXT_MACHINE /// The product or patch instance exists in the per-machine context. /// /// /// /// /// /// The dwOptions value determines the interpretation of the szProductCodeOrPatchCode value and the type of sources to clear. This /// parameter must be a combination of one of the following MSISOURCETYPE_* constants and one of the following MSICODE_* constants. /// /// /// /// Flag /// Meaning /// /// /// MSISOURCETYPE_MEDIA /// The source is media. /// /// /// MSISOURCETYPE_NETWORK /// The source is a network type. /// /// /// MSISOURCETYPE_URL /// The source is a URL type. /// /// /// MSICODE_PATCH /// szProductCodeOrPatchCode is a patch code. /// /// /// MSICODE_PRODUCT /// szProductCodeOrPatchCode is a product code. /// /// /// /// /// /// /// Value /// Meaning /// /// /// ERROR_ACCESS_DENIED /// The user does not have the ability to add or move a source. Does not indicate whether the product or patch was found. /// /// /// ERROR_BAD_CONFIGURATION /// The configuration data is corrupt. /// /// /// ERROR_INSTALL_SERVICE_FAILURE /// Cannot access the Windows Installer service. /// /// /// ERROR_INVALID_PARAMETER /// An invalid parameter was passed to the function. /// /// /// ERROR_SUCCESS /// All sources of the specified type were removed. /// /// /// ERROR_UNKNOWN_PRODUCT /// The specified product is unknown. /// /// /// ERROR_UNKNOWN_PATCH /// The specified patch is unknown. /// /// /// ERROR_FUNCTION_FAILED /// Unexpected internal failure. /// /// /// /// /// /// Administrators can modify the installation of a product or patch instance that exists under the machine context or under their /// own per-user context (managed or unmanaged.) They can modify the installation of a product or patch instance that exists under /// any user's per-user-managed context. Administrators cannot modify another user's installation of a product or patch instance /// that exists under that other user's per-user-unmanaged context. /// /// /// Non-administrators cannot modify the installation of a product or patch instance that exists under another user's per-user /// context (managed or unmanaged.) They can modify the installation of a product or patch instance that exists under their own /// per-user-unmanaged context. They can modify the installation of a product or patch instance under the machine context or their /// own per-user-managed context only if they are enabled to browse for a product or patch source. Users can be enabled to browse /// for sources by setting policy, for more information, see DisableBrowse, AllowLockdownBrowse, and AlwaysInstallElevated policies. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msisourcelistclearallexa UINT MsiSourceListClearAllExA( LPCSTR // szProductCodeOrPatchCode, LPCSTR szUserSid, MSIINSTALLCONTEXT dwContext, DWORD dwOptions ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiSourceListClearAllExA")] public static extern Win32Error MsiSourceListClearAllEx([MarshalAs(UnmanagedType.LPTStr)] string szProductCodeOrPatchCode, [Optional, MarshalAs(UnmanagedType.LPTStr)] string szUserSid, MSIINSTALLCONTEXT dwContext, uint dwOptions); /// /// The MsiSourceListClearMediaDisk function provides the ability to remove an existing registered disk under the media /// source for a product or patch in a specific context. /// /// /// The ProductCode or patch GUID of the product or patch. Use a null-terminated string. If the string is longer than 39 characters, /// the function fails and returns ERROR_INVALID_PARAMETER. This parameter cannot be NULL. /// /// /// /// This parameter can be a string SID that specifies the user account that contains the product or patch. The SID is not validated /// or resolved. An incorrect SID can return ERROR_UNKNOWN_PRODUCT or ERROR_UNKNOWN_PATCH. /// /// /// /// Type of SID /// Meaning /// /// /// NULL /// /// NULL denotes the currently logged on user. When referencing the current user account, szUserSID can be NULL and dwContext can be /// MSIINSTALLCONTEXT_USERMANAGED or MSIINSTALLCONTEXT_USERUNMANAGED. /// /// /// /// User SID /// Specifies enumeration for a particular user in the system. An example of user SID is "S-1-3-64-2415071341-1358098788-3127455600-2561". /// /// /// /// Note The special SID string s-1-5-18 (system) cannot be used to enumerate products or patches installed as per-machine. /// Setting the SID value to s-1-5-18 returns ERROR_INVALID_PARAMETER. When dwContext is set to MSIINSTALLCONTEXT_MACHINE only, /// szUserSid must be NULL. /// /// /// Note The special SID string s-1-1-0 (everyone) should not be used. Setting the SID value to s-1-1-0 fails and returns ERROR_INVALID_PARAM. /// /// /// /// /// This parameter specifies the context of the product or patch instance. This parameter can contain one of the following values. /// /// /// /// Type of context /// Meaning /// /// /// MSIINSTALLCONTEXT_USERMANAGED /// The product or patch instance exists in the per-user-managed context. /// /// /// MSIINSTALLCONTEXT_USERUNMANAGED /// The product or patch instance exists in the per-user-unmanaged context. /// /// /// MSIINSTALLCONTEXT_MACHINE /// The product or patch instance exists in the per-machine context. /// /// /// /// /// The dwOptions value specifies the meaning of szProductCodeOrPatchCode. /// /// /// Flag /// Meaning /// /// /// MSICODE_PRODUCT /// szProductCodeOrPatchCode is a product code GUID. /// /// /// MSICODE_PATCH /// szProductCodeOrPatchCode is a patch code GUID. /// /// /// /// This parameter provides the ID of the disk being removed. /// /// The MsiSourceListClearMediaDisk function returns the following values. /// /// /// Value /// Meaning /// /// /// ERROR_ACCESS_DENIED /// /// The user does not have the ability to read the specified media source or the specified product or patch. This does not indicate /// whether a media source, product or patch was found. /// /// /// /// ERROR_BAD_CONFIGURATION /// The configuration data is corrupt. /// /// /// ERROR_INSTALL_SERVICE_FAILURE /// The Windows Installer service could not be accessed. /// /// /// ERROR_INVALID_PARAMETER /// An invalid parameter was passed to the function. /// /// /// ERROR_SUCCESS /// The value was successfully removed or not found. /// /// /// ERROR_UNKNOWN_PATCH /// The patch was not found. /// /// /// ERROR_UNKNOWN_PRODUCT /// The product was not found. /// /// /// ERROR_FUNCTION_FAILED /// Unexpected internal failure. /// /// /// /// /// /// Administrators can modify the installation of a product or patch instance that exists under the machine context or under their /// own per-user context (managed or unmanaged.) They can modify the installation of a product or patch instance that exists under /// any user's per-user-managed context. Administrators cannot modify another user's installation of a product or patch instance /// that exists under that other user's per-user-unmanaged context. /// /// /// Non-administrators cannot modify the installation of a product or patch instance that exists under another user's per-user /// context (managed or unmanaged.) They can modify the installation of a product or patch instance that exists under their own /// per-user-unmanaged context. They can modify the installation of a product or patch instance under the machine context or their /// own per-user-managed context only if they are enabled to browse for a product or patch source. Users can be enabled to browse /// for sources by setting policy. For more information, see the DisableBrowse, AllowLockdownBrowse, and AlwaysInstallElevated policies. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msisourcelistclearmediadiska UINT MsiSourceListClearMediaDiskA( // LPCSTR szProductCodeOrPatchCode, LPCSTR szUserSid, MSIINSTALLCONTEXT dwContext, DWORD dwOptions, DWORD dwDiskId ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiSourceListClearMediaDiskA")] public static extern Win32Error MsiSourceListClearMediaDisk([MarshalAs(UnmanagedType.LPTStr)] string szProductCodeOrPatchCode, [Optional, MarshalAs(UnmanagedType.LPTStr)] string szUserSid, MSIINSTALLCONTEXT dwContext, MSICODE dwOptions, uint dwDiskId); /// /// The MsiSourceListClearSource function removes an existing source for a product or patch in a specified context. The patch /// registration is also removed if the sole source of the patch gets removed and if the patch is not installed by any client in the /// same context. Specifying that MsiSourceListClearSource remove the current source for this product or patch forces the /// installer to search the source list for a source the next time a source is required. /// /// /// The ProductCode or patch GUID of the product or patch. Use a null-terminated string. If the string is longer than 39 characters, /// the function fails and returns ERROR_INVALID_PARAMETER. This parameter cannot be NULL. /// /// /// /// This parameter can be a string SID that specifies the user account that contains the product or patch. The SID is not validated /// or resolved. An incorrect SID can return ERROR_UNKNOWN_PRODUCT or ERROR_UNKNOWN_PATCH. When referencing a machine /// context, szUserSID must be NULL and dwContext must be MSIINSTALLCONTEXT_MACHINE. /// /// /// /// Type of SID /// Meaning /// /// /// NULL /// /// NULL denotes the currently logged on user. When referencing the current user account, szUserSID can be NULL and dwContext can be /// MSIINSTALLCONTEXT_USERMANAGED or MSIINSTALLCONTEXT_USERUNMANAGED. /// /// /// /// User SID /// Specifies enumeration for a particular user in the system. An example of a user SID is "S-1-3-64-2415071341-1358098788-3127455600-2561". /// /// /// /// Note The special SID string "S-1-5-18" (system) cannot be used to enumerate products or patches installed as per-machine. /// Setting the SID value to "S-1-5-18" returns ERROR_INVALID_PARAMETER. /// /// /// Note The special SID string "S-1-1-0" (everyone) should not be used. Setting the SID value to "S-1-1-0" fails and returns ERROR_INVALID_PARAM. /// /// /// /// /// This parameter specifies the context of the product or patch instance. This parameter can contain one of the following values. /// /// /// /// Type of context /// Meaning /// /// /// MSIINSTALLCONTEXT_USERMANAGED /// The product or patch instance exists in the per-user-managed context. /// /// /// MSIINSTALLCONTEXT_USERUNMANAGED /// The product or patch instance exists in the per-user-unmanaged context. /// /// /// MSIINSTALLCONTEXT_MACHINE /// The product or patch instance exists in the per-machine context. /// /// /// /// /// /// The dwOptions value determines the interpretation of the szProductCodeOrPatchCode value and the type of sources to clear. This /// parameter must be a combination of one of the following MSISOURCETYPE_ constants and one of the following MSICODE_ constants. /// /// /// /// Flag /// Meaning /// /// /// MSISOURCETYPE_NETWORK /// The source is a network type. /// /// /// MSISOURCETYPE_URL /// The source is a URL type. /// /// /// MSICODE_PRODUCT /// szProductCodeOrPatchCode is a product code. /// /// /// MSICODE_PATCH /// szProductCodeOrPatchCode is a patch code. /// /// /// /// /// Source to remove. This parameter is expected to contain only the path without the filename. The filename is already registered /// as "PackageName" and can be manipulated through MsiSourceListSetInfo. This argument is required. /// /// /// The MsiSourceListClearSource function returns the following values. /// /// /// Value /// Meaning /// /// /// ERROR_ACCESS_DENIED /// The user does not have the ability to remove a source. Does not indicate whether the product or patch was found. /// /// /// ERROR_BAD_CONFIGURATION /// The configuration data is corrupt. /// /// /// ERROR_INSTALL_SERVICE_FAILURE /// Could not access the Windows Installer service /// /// /// ERROR_INVALID_PARAMETER /// An invalid parameter was passed to the function. /// /// /// ERROR_SUCCESS /// The source was removed or not found. /// /// /// ERROR_UNKNOWN_PATCH /// The specified patch is unknown. /// /// /// ERROR_UNKNOWN_PRODUCT /// The specified product is unknown. /// /// /// ERROR_FUNCTION_FAILED /// Unexpected internal failure. /// /// /// /// /// /// Administrators can modify the installation of a product or patch instance that exists under the machine context or under their /// own per-user context (managed or unmanaged.) They can modify the installation of a product or patch instance that exists under /// any user's per-user-managed context. Administrators cannot modify another user's installation of a product or patch instance /// that exists under that other user's per-user-unmanaged context. /// /// /// Non-administrators cannot modify the installation of a product or patch instance that exists under another user's per-user /// context (managed or unmanaged.) They can modify the installation of a product or patch instance that exists under their own /// per-user-unmanaged context. They can modify the installation of a product or patch instance under the machine context or their /// own per-user-managed context only if they are enabled to browse for a product or patch source. Users can be enabled to browse /// for sources by setting policy. For more information, see the DisableBrowse, AllowLockdownBrowse, and AlwaysInstallElevated policies. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msisourcelistclearsourcea UINT MsiSourceListClearSourceA( LPCSTR // szProductCodeOrPatchCode, LPCSTR szUserSid, MSIINSTALLCONTEXT dwContext, DWORD dwOptions, LPCSTR szSource ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiSourceListClearSourceA")] public static extern Win32Error MsiSourceListClearSource([MarshalAs(UnmanagedType.LPTStr)] string szProductCodeOrPatchCode, [Optional, MarshalAs(UnmanagedType.LPTStr)] string szUserSid, MSIINSTALLCONTEXT dwContext, uint dwOptions, [MarshalAs(UnmanagedType.LPTStr)] string szSource); /// /// The MsiSourceListEnumMediaDisks function enumerates the list of disks registered for the media source for a patch or product. /// /// /// The ProductCode or patch GUID of the product or patch. Use a null-terminated string. If the string is longer than 39 characters, /// the function fails and returns ERROR_INVALID_PARAMETER. This parameter cannot be NULL. /// /// /// /// A string SID that specifies the user account that contains the product or patch. The SID is not validated or resolved. An /// incorrect SID can return ERROR_UNKNOWN_PRODUCT or ERROR_UNKNOWN_PATCH. When referencing a machine context, szUserSID must be /// NULL and dwContext must be MSIINSTALLCONTEXT_MACHINE. /// /// /// /// Type of SID /// Meaning /// /// /// NULL /// /// A NULL denotes the currently logged on user. When referencing the current user account, szUserSID can be NULL and dwContext can /// be MSIINSTALLCONTEXT_USERMANAGED or MSIINSTALLCONTEXT_USERUNMANAGED. /// /// /// /// User SID /// An enumeration for a specific user in the system. An example of a user SID is "S-1-3-64-2415071341-1358098788-3127455600-2561". /// /// /// s-1-1-0 /// The special SID string s-1-1-0 (everyone) specifies enumeration across all users in the system. /// /// /// /// Note The special SID string s-1-5-18 (system) cannot be used to enumerate products or patches installed as per-machine. /// Setting the SID value to s-1-5-18 returns ERROR_INVALID_PARAMETER. /// /// /// /// /// This parameter specifies the context of the product or patch instance. This parameter can contain one of the following values. /// /// /// /// Type of context /// Meaning /// /// /// MSIINSTALLCONTEXT_USERMANAGED /// The product or patch instance exists in the per-user-managed context. /// /// /// MSIINSTALLCONTEXT_USERUNMANAGED /// The product or patch instance exists in the per-user-unmanaged context. /// /// /// MSIINSTALLCONTEXT_MACHINE /// The product or patch instance exists in the per-machine context. /// /// /// /// /// The dwOptions value that specifies the meaning of szProductCodeOrPatchCode. /// /// /// Flag /// Meaning /// /// /// MSICODE_PRODUCT /// szProductCodeOrPatchCode is a product code GUID. /// /// /// MSICODE_PATCH /// szProductCodeOrPatchCode is a patch code GUID. /// /// /// /// /// The index of the source to retrieve. This parameter must be 0 (zero) for the first call to the /// MsiSourceListEnumMediaDisks function, and then incremented for subsequent calls until the function returns ERROR_NO_MORE_ITEMS. /// /// /// On entry to MsiSourceListEnumMediaDisks this parameter provides a pointer to a DWORD to receive the ID of the disk /// that is being enumerated. This parameter is optional. /// /// /// /// An output buffer that receives the volume label of the disk that is being enumerated. This buffer should be large enough to /// contain the information. If the buffer is too small, the function returns ERROR_MORE_DATA and sets *pcchVolumeLabel to the /// number of TCHAR in the value, not including the terminating NULL character. /// /// /// If szVolumeLabel and pcchVolumeLabel are both set to NULL, the function returns ERROR_SUCCESS if the value exists, /// without retrieving the value. /// /// /// /// /// A pointer to a variable that specifies the number of TCHAR in the szVolumeLabel buffer. When the function returns, this /// parameter is the number of TCHAR in the received value, not including the terminating null character. /// /// This parameter can be set to NULL only if szVolumeLabel is also NULL, otherwise the function returns ERROR_INVALID_PARAMETER. /// /// /// /// An output buffer that receives the disk prompt of the disk that is being enumerated. This buffer should be large enough to /// contain the information. If the buffer is too small, the function returns ERROR_MORE_DATA and sets *pcchDiskPrompt to the number /// of TCHAR in the value, not including the terminating NULL character. /// /// /// If the szDiskPrompt is set to NULL and pcchDiskPrompt is set to a valid pointer, the function returns ERROR_SUCCESS and /// sets *pcchDiskPrompt to the number of TCHAR in the value, not including the terminating NULL character. The function can /// then be called again to retrieve the value, with szDiskPrompt buffer large enough to contain *pcchDiskPrompt + 1 characters. /// /// /// If szDiskPrompt and pcchDiskPrompt are both set to NULL, the function returns ERROR_SUCCESS if the value exists, without /// retrieving the value. /// /// /// /// /// A pointer to a variable that specifies the number of TCHAR in the szDiskPrompt buffer. When the function returns, this /// parameter is set to the size of the requested value whether or not the function copies the value into the specified buffer. The /// size is returned as the number of TCHAR in the requested value, not including the terminating null character. /// /// This parameter can be set to NULL only if szDiskPrompt is also NULL, otherwise the function returns ERROR_INVALID_PARAMETER. /// /// /// The MsiSourceListEnumMediaDisks function returns the following values. /// /// /// Value /// Meaning /// /// /// ERROR_ACCESS_DENIED /// /// The user does not have the ability to read the specified media source or the specified product or patch. This does not indicate /// whether a media source, product, or patch is found. /// /// /// /// ERROR_BAD_CONFIGURATION /// The configuration data is corrupt. /// /// /// ERROR_INVALID_PARAMETER /// An invalid parameter is passed to the function. /// /// /// ERROR_NO_MORE_ITEMS /// There are no more disks registered for this product or patch. /// /// /// ERROR_SUCCESS /// The value is enumerated successfully. /// /// /// ERROR_UNKNOWN_PATCH /// The patch is not found. /// /// /// ERROR_UNKNOWN_PRODUCT /// The product is not found. /// /// /// ERROR_MORE_DATA /// The buffer that is provided is too small to contain the requested information. /// /// /// ERROR_FUNCTION_FAILED /// Unexpected internal failure. /// /// /// /// /// /// When making multiple calls to MsiSourceListEnumMediaDisks to enumerate all the sources for a single product instance, /// each call must be made from the same thread. /// /// /// An administrator can enumerate per-user unmanaged and managed installations for themselves, per-machine installations, and /// per-user managed installations for any user. An administrator cannot enumerate per-user unmanaged installations for other users. /// Non-administrators can only enumerate their own per-user unmanaged and managed installations and per-machine installations. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msisourcelistenummediadisksa UINT MsiSourceListEnumMediaDisksA( // LPCSTR szProductCodeOrPatchCode, LPCSTR szUserSid, MSIINSTALLCONTEXT dwContext, DWORD dwOptions, DWORD dwIndex, LPDWORD // pdwDiskId, LPSTR szVolumeLabel, LPDWORD pcchVolumeLabel, LPSTR szDiskPrompt, LPDWORD pcchDiskPrompt ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiSourceListEnumMediaDisksA")] public static extern Win32Error MsiSourceListEnumMediaDisks([MarshalAs(UnmanagedType.LPTStr)] string szProductCodeOrPatchCode, [MarshalAs(UnmanagedType.LPTStr)] string szUserSid, MSIINSTALLCONTEXT dwContext, MSICODE dwOptions, uint dwIndex, out uint pdwDiskId, [Out, Optional, MarshalAs(UnmanagedType.LPTStr)] StringBuilder szVolumeLabel, ref uint pcchVolumeLabel, [Out, Optional, MarshalAs(UnmanagedType.LPTStr)] StringBuilder szDiskPrompt, ref uint pcchDiskPrompt); /// /// The MsiSourceListEnumMediaDisks function enumerates the list of disks registered for the media source for a patch or product. /// /// /// The ProductCode or patch GUID of the product or patch. Use a null-terminated string. If the string is longer than 39 characters, /// the function fails and returns ERROR_INVALID_PARAMETER. This parameter cannot be NULL. /// /// /// /// A string SID that specifies the user account that contains the product or patch. The SID is not validated or resolved. An /// incorrect SID can return ERROR_UNKNOWN_PRODUCT or ERROR_UNKNOWN_PATCH. When referencing a machine context, szUserSID must be /// NULL and dwContext must be MSIINSTALLCONTEXT_MACHINE. /// /// /// /// Type of SID /// Meaning /// /// /// NULL /// /// A NULL denotes the currently logged on user. When referencing the current user account, szUserSID can be NULL and dwContext can /// be MSIINSTALLCONTEXT_USERMANAGED or MSIINSTALLCONTEXT_USERUNMANAGED. /// /// /// /// User SID /// An enumeration for a specific user in the system. An example of a user SID is "S-1-3-64-2415071341-1358098788-3127455600-2561". /// /// /// s-1-1-0 /// The special SID string s-1-1-0 (everyone) specifies enumeration across all users in the system. /// /// /// /// Note The special SID string s-1-5-18 (system) cannot be used to enumerate products or patches installed as per-machine. /// Setting the SID value to s-1-5-18 returns ERROR_INVALID_PARAMETER. /// /// /// /// /// This parameter specifies the context of the product or patch instance. This parameter can contain one of the following values. /// /// /// /// Type of context /// Meaning /// /// /// MSIINSTALLCONTEXT_USERMANAGED /// The product or patch instance exists in the per-user-managed context. /// /// /// MSIINSTALLCONTEXT_USERUNMANAGED /// The product or patch instance exists in the per-user-unmanaged context. /// /// /// MSIINSTALLCONTEXT_MACHINE /// The product or patch instance exists in the per-machine context. /// /// /// /// /// The dwOptions value that specifies the meaning of szProductCodeOrPatchCode. /// /// /// Flag /// Meaning /// /// /// MSICODE_PRODUCT /// szProductCodeOrPatchCode is a product code GUID. /// /// /// MSICODE_PATCH /// szProductCodeOrPatchCode is a patch code GUID. /// /// /// /// /// The index of the source to retrieve. This parameter must be 0 (zero) for the first call to the /// MsiSourceListEnumMediaDisks function, and then incremented for subsequent calls until the function returns ERROR_NO_MORE_ITEMS. /// /// /// On entry to MsiSourceListEnumMediaDisks this parameter provides a pointer to a DWORD to receive the ID of the disk /// that is being enumerated. This parameter is optional. /// /// /// /// An output buffer that receives the volume label of the disk that is being enumerated. This buffer should be large enough to /// contain the information. If the buffer is too small, the function returns ERROR_MORE_DATA and sets *pcchVolumeLabel to the /// number of TCHAR in the value, not including the terminating NULL character. /// /// /// If szVolumeLabel and pcchVolumeLabel are both set to NULL, the function returns ERROR_SUCCESS if the value exists, /// without retrieving the value. /// /// /// /// /// A pointer to a variable that specifies the number of TCHAR in the szVolumeLabel buffer. When the function returns, this /// parameter is the number of TCHAR in the received value, not including the terminating null character. /// /// This parameter can be set to NULL only if szVolumeLabel is also NULL, otherwise the function returns ERROR_INVALID_PARAMETER. /// /// /// /// An output buffer that receives the disk prompt of the disk that is being enumerated. This buffer should be large enough to /// contain the information. If the buffer is too small, the function returns ERROR_MORE_DATA and sets *pcchDiskPrompt to the number /// of TCHAR in the value, not including the terminating NULL character. /// /// /// If the szDiskPrompt is set to NULL and pcchDiskPrompt is set to a valid pointer, the function returns ERROR_SUCCESS and /// sets *pcchDiskPrompt to the number of TCHAR in the value, not including the terminating NULL character. The function can /// then be called again to retrieve the value, with szDiskPrompt buffer large enough to contain *pcchDiskPrompt + 1 characters. /// /// /// If szDiskPrompt and pcchDiskPrompt are both set to NULL, the function returns ERROR_SUCCESS if the value exists, without /// retrieving the value. /// /// /// /// /// A pointer to a variable that specifies the number of TCHAR in the szDiskPrompt buffer. When the function returns, this /// parameter is set to the size of the requested value whether or not the function copies the value into the specified buffer. The /// size is returned as the number of TCHAR in the requested value, not including the terminating null character. /// /// This parameter can be set to NULL only if szDiskPrompt is also NULL, otherwise the function returns ERROR_INVALID_PARAMETER. /// /// /// The MsiSourceListEnumMediaDisks function returns the following values. /// /// /// Value /// Meaning /// /// /// ERROR_ACCESS_DENIED /// /// The user does not have the ability to read the specified media source or the specified product or patch. This does not indicate /// whether a media source, product, or patch is found. /// /// /// /// ERROR_BAD_CONFIGURATION /// The configuration data is corrupt. /// /// /// ERROR_INVALID_PARAMETER /// An invalid parameter is passed to the function. /// /// /// ERROR_NO_MORE_ITEMS /// There are no more disks registered for this product or patch. /// /// /// ERROR_SUCCESS /// The value is enumerated successfully. /// /// /// ERROR_UNKNOWN_PATCH /// The patch is not found. /// /// /// ERROR_UNKNOWN_PRODUCT /// The product is not found. /// /// /// ERROR_MORE_DATA /// The buffer that is provided is too small to contain the requested information. /// /// /// ERROR_FUNCTION_FAILED /// Unexpected internal failure. /// /// /// /// /// /// When making multiple calls to MsiSourceListEnumMediaDisks to enumerate all the sources for a single product instance, /// each call must be made from the same thread. /// /// /// An administrator can enumerate per-user unmanaged and managed installations for themselves, per-machine installations, and /// per-user managed installations for any user. An administrator cannot enumerate per-user unmanaged installations for other users. /// Non-administrators can only enumerate their own per-user unmanaged and managed installations and per-machine installations. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msisourcelistenummediadisksa UINT MsiSourceListEnumMediaDisksA( // LPCSTR szProductCodeOrPatchCode, LPCSTR szUserSid, MSIINSTALLCONTEXT dwContext, DWORD dwOptions, DWORD dwIndex, LPDWORD // pdwDiskId, LPSTR szVolumeLabel, LPDWORD pcchVolumeLabel, LPSTR szDiskPrompt, LPDWORD pcchDiskPrompt ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiSourceListEnumMediaDisksA")] public static extern Win32Error MsiSourceListEnumMediaDisks([MarshalAs(UnmanagedType.LPTStr)] string szProductCodeOrPatchCode, [MarshalAs(UnmanagedType.LPTStr)] string szUserSid, MSIINSTALLCONTEXT dwContext, MSICODE dwOptions, uint dwIndex, out uint pdwDiskId, [Out, Optional, MarshalAs(UnmanagedType.LPTStr)] StringBuilder szVolumeLabel, [In, Optional] IntPtr pcchVolumeLabel, [Out, Optional, MarshalAs(UnmanagedType.LPTStr)] StringBuilder szDiskPrompt, [In, Optional] IntPtr pcchDiskPrompt); /// The MsiSourceListEnumSources function enumerates the sources in the source list of a specified patch or product. /// /// The ProductCode or patch GUID of the product or patch. Use a null-terminated string. If the string is longer than 39 characters, /// the function fails and returns ERROR_INVALID_PARAMETER. This parameter cannot be NULL. /// /// /// /// A string SID that specifies the user account that contains the product or patch. The SID is not validated or resolved. An /// incorrect SID can return ERROR_UNKNOWN_PRODUCT or ERROR_UNKNOWN_PATCH. When referencing a machine context, szUserSID must be /// NULL and dwContext must be MSIINSTALLCONTEXT_MACHINE. /// /// /// /// Type of SID /// Meaning /// /// /// NULL /// /// A NULL indicates the current user who is logged on. When referencing the current user account, szUserSID can be NULL and /// dwContext can be MSIINSTALLCONTEXT_USERMANAGED or MSIINSTALLCONTEXT_USERUNMANAGED. /// /// /// /// User SID /// An enumeration for a specific user in the system. An example of a user SID is "S-1-3-64-2415071341-1358098788-3127455600-2561". /// /// /// s-1-1-0 /// The special SID string s-1-1-0 (everyone) specifies enumeration across all users in the system. /// /// /// /// Note The special SID string s-1-5-18 (system) cannot be used to enumerate products or patches installed as per-machine. /// Setting the SID value to s-1-5-18 returns ERROR_INVALID_PARAMETER. /// /// /// /// The context of the product or patch instance. This parameter can contain one of the following values. /// /// /// Type of context /// Meaning /// /// /// MSIINSTALLCONTEXT_USERMANAGED /// The product or patch instance exists in the per-user-managed context. /// /// /// MSIINSTALLCONTEXT_USERUNMANAGED /// The product or patch instance exists in the per-user-unmanaged context. /// /// /// MSIINSTALLCONTEXT_MACHINE /// The product or patch instance exists in the per-machine context. /// /// /// /// /// /// The dwOptions value determines the interpretation of the szProductCodeOrPatchCode value and the type of sources to clear. This /// parameter must be a combination of one of the following MSISOURCETYPE_* constants and one of the following MSICODE_* constants. /// /// /// /// Flag /// Meaning /// /// /// MSISOURCETYPE_NETWORK /// The source is a network type. /// /// /// MSISOURCETYPE_URL /// The source is a URL type. /// /// /// MSICODE_PRODUCT /// szProductCodeOrPatchCode is a product code. /// /// /// MSICODE_PATCH /// szProductCodeOrPatchCode is a patch code. /// /// /// /// /// The index of the source to retrieve. This parameter must be 0 (zero) for the first call to the MsiSourceListEnumSources /// function, and then incremented for subsequent calls until the function returns ERROR_NO_MORE_ITEMS. The index should be /// incremented only if the previous call returned ERROR_SUCCESS. /// /// /// /// A pointer to a buffer that receives the path to the source that is being enumerated. This buffer should be large enough to /// contain the received value. If the buffer is too small, the function returns ERROR_MORE_DATA and sets *pcchSource to the number /// of TCHAR in the value, not including the terminating NULL character. /// /// /// If szSource is set to NULL and pcchSource is set to a valid pointer, the function returns ERROR_SUCCESS and sets /// *pcchSource to the number of TCHAR in the value, not including the terminating NULL character. The function can then be /// called again to retrieve the value, with szSource buffer large enough to contain *pcchSource + 1 characters. /// /// /// If szSource and pcchSource are both set to NULL, the function returns ERROR_SUCCESS if the value exists, without /// retrieving the value. /// /// /// /// /// A pointer to a variable that specifies the number of TCHAR in the szSource buffer. When the function returns, this /// parameter is set to the size of the requested value whether or not the function copies the value into the specified buffer. The /// size is returned as the number of TCHAR in the requested value, not including the terminating null character. /// /// This parameter can be set to NULL only if szSource is also NULL, otherwise the function returns ERROR_INVALID_PARAMETER. /// /// /// The MsiSourceListEnumSources function returns the following values. /// /// /// Value /// Meaning /// /// /// ERROR_ACCESS_DENIED /// /// The user does not have the ability to read the specified source list. This does not indicate whether a product or patch is found. /// /// /// /// ERROR_BAD_CONFIGURATION /// The configuration data is corrupt. /// /// /// ERROR_INVALID_PARAMETER /// An invalid parameter is passed to the function. /// /// /// ERROR_MORE_DATA /// The provided buffer is not sufficient to contain the requested data. /// /// /// ERROR_NO_MORE_ITEMS /// There are no more sources in the specified list to enumerate. /// /// /// ERROR_SUCCESS /// A source is enumerated successfully. /// /// /// ERROR_UNKNOWN_PATCH /// The patch specified is not installed on the computer in the specified contexts. /// /// /// ERROR_UNKNOWN_PRODUCT /// The product specified is not installed on the computer in the specified contexts. /// /// /// ERROR_FUNCTION_FAILED /// Unexpected internal failure. /// /// /// /// /// /// When making multiple calls to MsiSourceListEnumSources to enumerate all sources for a single product instance, each call /// must be made from the same thread. /// /// /// An administrator can enumerate per-user unmanaged and managed installations for themselves, per-machine installations, and /// per-user managed installations for any user. An administrator cannot enumerate per-user unmanaged installations for other users. /// Non-administrators can only enumerate their own per-user unmanaged and managed installations and per-machine installations. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msisourcelistenumsourcesa UINT MsiSourceListEnumSourcesA( LPCSTR // szProductCodeOrPatchCode, LPCSTR szUserSid, MSIINSTALLCONTEXT dwContext, DWORD dwOptions, DWORD dwIndex, LPSTR szSource, LPDWORD // pcchSource ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiSourceListEnumSourcesA")] public static extern Win32Error MsiSourceListEnumSources([MarshalAs(UnmanagedType.LPTStr)] string szProductCodeOrPatchCode, [Optional, MarshalAs(UnmanagedType.LPTStr)] string szUserSid, MSIINSTALLCONTEXT dwContext, uint dwOptions, uint dwIndex, [Out, Optional, MarshalAs(UnmanagedType.LPTStr)] StringBuilder szSource, ref uint pcchSource); /// /// The MsiSourceListForceResolution function forces the installer to search the source list for a valid product source the /// next time a source is required. For example, when the installer performs an installation or reinstallation, or when it requires /// the path for a component that is set to run from source. /// /// The ProductCode of the product to modify. /// /// /// The user name for a per-user installation. The user name should always be in the format of DOMAIN\USERNAME (or /// MACHINENAME\USERNAME for a local user). /// /// An empty string or NULL for a per-machine installation. /// /// Reserved for future use. This value must be set to 0. /// /// The MsiSourceListForceResolution function returns the following values. /// /// /// Value /// Meaning /// /// /// ERROR_ACCESS_DENIED /// The caller does not have sufficient access to force resolution for the product. /// /// /// ERROR_BAD_CONFIGURATION /// The configuration data is corrupt. /// /// /// ERROR_BAD_USER_NAME /// The specified user is not a valid user. /// /// /// ERROR_FUNCTION_FAILED /// The function could not complete. /// /// /// ERROR_INSTALL_SERVICE_FAILURE /// The installation service could not be accessed. /// /// /// ERROR_INVALID_PARAMETER /// An invalid parameter was passed to the function. /// /// /// ERROR_SUCCESS /// The function succeeded. /// /// /// ERROR_UNKNOWN_PRODUCT /// The specified product is unknown. /// /// /// /// /// /// An administrator can modify per-machine installations, their own per-user non-managed installations, and the per-user managed /// installations for any user. A non-administrator can only modify per-machine installations and their own (managed or non-managed) /// per-user installations. /// /// /// If the user name is an empty string or NULL, the function operates on the per-machine installation of the product. In /// this case, if the product is installed as per-user only, the function returns ERROR_UNKNOWN_PRODUCT. /// /// /// If the user name is not an empty string or NULL, it specifies the name of the user whose product installation is /// modified. If the user name is the current user name, the function first attempts to modify a non-managed installation of the /// product. If no non-managed installation of the product can be found, the function then tries to modify a managed per-user /// installation of the product. If no managed or unmanaged per-user installations of the product can be found, the function returns /// ERROR_UNKNOWN_PRODUCT, even if the product is installed per-machine. /// /// /// This function can not modify a non-managed installation for any user besides the current user. If the user name is not an empty /// string or NULL, but is not the current user, the function only checks for a managed per-user installation of the product /// for the specified user. If the product is not installed as managed per-user for the specified user, the function returns /// ERROR_UNKNOWN_PRODUCT, even if the product is installed per-machine. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msisourcelistforceresolutiona UINT MsiSourceListForceResolutionA( // LPCSTR szProduct, LPCSTR szUserName, DWORD dwReserved ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiSourceListForceResolutionA")] public static extern Win32Error MsiSourceListForceResolution([MarshalAs(UnmanagedType.LPTStr)] string szProduct, [Optional, MarshalAs(UnmanagedType.LPTStr)] string szUserName, uint dwReserved = 0); /// /// The MsiSourceListForceResolutionEx function removes the registration of the property called "LastUsedSource". This /// function does not affect the registered source list. Whenever the installer requires the source to reinstall a product or patch, /// it first tries the source registered as "LastUsedSource". If that fails, or if that registration is missing, the installer /// searches the other registered sources until it finds a valid source or until the list of sources is exhausted. Clearing the /// "LastUsedSource" registration forces the installer to do a source resolution against the registered sources the next time it /// requires the source. /// /// /// The ProductCode or patch GUID of the product or patch. Use a null-terminated string. If the string is longer than 39 characters, /// the function fails and returns ERROR_INVALID_PARAMETER. This parameter cannot be NULL. /// /// /// This parameter can be a string SID that specifies the user account that contains the product or patch. The SID is not validated /// or resolved. An incorrect SID can return ERROR_UNKNOWN_PRODUCT or ERROR_UNKNOWN_PATCH. When referencing a machine context, /// szUserSID must be NULL and dwContext must be MSIINSTALLCONTEXT_MACHINE. Using the machine SID ("S-1-5-18") returns /// ERROR_INVALID PARAMETER. When referencing the current user account, szUserSID can be NULL and dwContext can be /// MSIINSTALLCONTEXT_USERMANAGED or MSIINSTALLCONTEXT_USERUNMANAGED. /// /// /// /// This parameter specifies the context of the product or patch instance. This parameter can contain one of the following values. /// /// /// /// Type of context /// Meaning /// /// /// MSIINSTALLCONTEXT_USERMANAGED /// The product or patch instance exists in the per-user-managed context. /// /// /// MSIINSTALLCONTEXT_USERUNMANAGED /// The product or patch instance exists in the per-user-unmanaged context. /// /// /// MSIINSTALLCONTEXT_MACHINE /// The product or patch instance exists in the per-machine context. /// /// /// /// /// The dwOptions value determines the interpretation of the szProductCodeOrPatchCode value . /// /// /// Flag /// Meaning /// /// /// MSICODE_PRODUCT /// szProductCodeOrPatchCode is a product code. /// /// /// MSICODE_PATCH /// szProductCodeOrPatchCode is a patch code. /// /// /// /// /// The MsiSourceListForceResolutionEx function returns the following values. /// /// /// Value /// Meaning /// /// /// ERROR_ACCESS_DENIED /// /// The user does not have the ability to modify the specified source list. Does not indicate whether the product or patch was found. /// /// /// /// ERROR_BAD_CONFIGURATION /// The configuration data is corrupt. /// /// /// ERROR_INSTALL_SERVICE_FAILURE /// Could not access the Windows Installer service /// /// /// ERROR_INVALID_PARAMETER /// An invalid parameter was passed to the function. /// /// /// ERROR_SUCCESS /// The "LastUsedSource" registration was cleared. /// /// /// ERROR_UNKNOWN_PATCH /// The patch was not found. /// /// /// ERROR_UNKNOWN_PRODUCT /// The specified product or patch was not found. /// /// /// ERROR_FUNCTION_FAILED /// Unexpected internal failure. /// /// /// /// /// /// Administrators can modify the installation of a product or patch instance that exists under the machine context or under their /// own per-user context (managed or unmanaged.) They can modify the installation of a product or patch instance that exists under /// any user's per-user-managed context. Administrators cannot modify another user's installation of a product or patch instance /// that exists under that other user's per-user-unmanaged context. /// /// /// Non-administrators cannot modify the installation of a product or patch instance that exists under another user's per-user /// context (managed or unmanaged.) They can modify the installation of a product or patch instance that exists under their own /// per-user-unmanaged context. They can modify the installation of a product or patch instance under the machine context or their /// own per-user-managed context only if they are enabled to browse for a product or patch source. Users can be enabled to browse /// for sources by setting policy, for more information, see DisableBrowse, AllowLockdownBrowse, and AlwaysInstallElevated policies. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msisourcelistforceresolutionexa UINT // MsiSourceListForceResolutionExA( LPCSTR szProductCodeOrPatchCode, LPCSTR szUserSid, MSIINSTALLCONTEXT dwContext, DWORD dwOptions ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiSourceListForceResolutionExA")] public static extern Win32Error MsiSourceListForceResolutionEx([MarshalAs(UnmanagedType.LPTStr)] string szProductCodeOrPatchCode, [Optional, MarshalAs(UnmanagedType.LPTStr)] string szUserSid, MSIINSTALLCONTEXT dwContext, MSICODE dwOptions); /// /// The MsiSourceListGetInfo function retrieves information about the source list for a product or patch in a specific context. /// /// /// The ProductCode or patch GUID of the product or patch. Use a null-terminated string. If the string is longer than 39 characters, /// the function fails and returns ERROR_INVALID_PARAMETER. This parameter cannot be NULL. /// /// /// /// This parameter can be a string security identifier (SID) that specifies the user account that contains the product or patch. The /// SID is not validated or resolved. An incorrect SID can return ERROR_UNKNOWN_PRODUCT or ERROR_UNKNOWN_PATCH. When referencing a /// machine context, szUserSID must be NULL and dwContext must be MSIINSTALLCONTEXT_MACHINE. /// /// /// /// Type of SID /// Meaning /// /// /// NULL /// /// NULL denotes the currently logged on user. When referencing the current user account, szUserSID can be NULL and dwContext can be /// MSIINSTALLCONTEXT_USERMANAGED or MSIINSTALLCONTEXT_USERUNMANAGED. /// /// /// /// User SID /// Specifies enumeration for a specific user in the system. An example of a user SID is "S-1-3-64-2415071341-1358098788-3127455600-2561". /// /// /// /// Note The special SID string s-1-5-18 (system) cannot be used to enumerate products or patches installed as per-machine. /// Setting the SID value to s-1-5-18 returns ERROR_INVALID_PARAMETER. /// /// /// Note The special SID string s-1-1-0 (everyone) should not be used. Setting the SID value to s-1-1-0 fails and returns ERROR_INVALID_PARAM. /// /// /// /// /// This parameter specifies the context of the product or patch instance. This parameter can contain one of the following values. /// /// /// /// Type of context /// Meaning /// /// /// MSIINSTALLCONTEXT_USERMANAGED /// The product or patch instance exists in the per-user-managed context. /// /// /// MSIINSTALLCONTEXT_USERUNMANAGED /// The product or patch instance exists in the per-user-unmanaged context. /// /// /// MSIINSTALLCONTEXT_MACHINE /// The product or patch instance exists in the per-machine context. /// /// /// /// /// The dwOptions value specifies the meaning of szProductCodeOrPatchCode. /// /// /// Flag /// Meaning /// /// /// MSICODE_PRODUCT /// szProductCodeOrPatchCode is a product code GUID. /// /// /// MSICODE_PATCH /// szProductCodeOrPatchCode is a patch code GUID. /// /// /// /// /// /// A null-terminated string that specifies the property value to retrieve. The szProperty parameter can be one of the following values. /// /// /// /// Name /// Meaning /// /// /// INSTALLPROPERTY_MEDIAPACKAGEPATH "MediaPackagePath" /// The path relative to the root of the installation media. /// /// /// INSTALLPROPERTY_DISKPROMPT "DiskPrompt" /// The prompt template that is used when prompting the user for installation media. /// /// /// INSTALLPROPERTY_LASTUSEDSOURCE "LastUsedSource" /// The most recently used source location for the product. /// /// /// INSTALLPROPERTY_LASTUSEDTYPE "LastUsedType" /// /// An "n" if the last-used source is a network location. A "u" if the last used source is a URL location. An "m" if the last used /// source is media. An empty string ("") if there is no last used source. /// /// /// /// INSTALLPROPERTY_PACKAGENAME "PackageName" /// The name of the Windows Installer package or patch package on the source. /// /// /// /// /// /// An output buffer that receives the information. This buffer should be large enough to contain the information. If the buffer is /// too small, the function returns ERROR_MORE_DATA and sets *pcchValue to the number of TCHAR in the value, not including /// the terminating NULL character. /// /// /// If the szValue is set to NULL and pcchValue is set to a valid pointer, the function returns ERROR_SUCCESS and sets /// *pcchValue to the number of TCHAR in the value, not including the terminating NULL character. The function can then be /// called again to retrieve the value, with szValue buffer large enough to contain *pcchValue + 1 characters. /// /// /// If szValue and pcchValue are both set to NULL, the function returns ERROR_SUCCESS if the value exists, without retrieving /// the value. /// /// /// /// /// A pointer to a variable that specifies the number of TCHAR in the szValue buffer. When the function returns, this /// parameter is set to the size of the requested value whether or not the function copies the value into the specified buffer. The /// size is returned as the number of TCHAR in the requested value, not including the terminating null character. /// /// This parameter can be set to NULL only if szValue is also NULL, otherwise the function returns ERROR_INVALID_PARAMETER. /// /// /// The MsiSourceListGetInfo function returns the following values. /// /// /// Value /// Meaning /// /// /// ERROR_ACCESS_DENIED /// /// The user does not have the ability to read the specified source list. This does not indicate whether a product or patch is found. /// /// /// /// ERROR_BAD_CONFIGURATION /// The configuration data is corrupt. /// /// /// ERROR_INVALID_PARAMETER /// An invalid parameter is passed to the function. /// /// /// ERROR_MORE_DATA /// The provided buffer is not sufficient to contain the requested data. /// /// /// ERROR_SUCCESS /// The property is retrieved successfully. /// /// /// ERROR_UNKNOWN_PATCH /// The patch is not found. /// /// /// ERROR_UNKNOWN_PRODUCT /// The product is not found. /// /// /// ERROR_UNKNOWN_PROPERTY /// The source property is not found. /// /// /// ERROR_FUNCTION_FAILED /// An unexpected internal failure. /// /// /// /// /// /// Administrators can modify the installation of a product or patch instance that exists under the machine context or under their /// own per-user context (managed or unmanaged.) They can modify the installation of a product or patch instance that exists under /// any user's per-user-managed context. Administrators cannot modify another user's installation of a product or patch instance /// that exists under that other user's per-user-unmanaged context. /// /// /// Non-administrators cannot modify the installation of a product or patch instance that exists under another user's per-user /// context (managed or unmanaged.) They can modify the installation of a product or patch instance that exists under their own /// per-user-unmanaged context. They can modify the installation of a product or patch instance under the machine context or their /// own per-user-managed context only if they are enabled to browse for a product or patch source. Users can be enabled to browse /// for sources by setting policy. For more information, see DisableBrowse, AllowLockdownBrowse, and AlwaysInstallElevated policies. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msisourcelistgetinfoa UINT MsiSourceListGetInfoA( LPCSTR // szProductCodeOrPatchCode, LPCSTR szUserSid, MSIINSTALLCONTEXT dwContext, DWORD dwOptions, LPCSTR szProperty, LPSTR szValue, // LPDWORD pcchValue ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiSourceListGetInfoA")] public static extern Win32Error MsiSourceListGetInfo([MarshalAs(UnmanagedType.LPTStr)] string szProductCodeOrPatchCode, [Optional, MarshalAs(UnmanagedType.LPTStr)] string szUserSid, MSIINSTALLCONTEXT dwContext, MSICODE dwOptions, [MarshalAs(UnmanagedType.LPTStr)] string szProperty, [Out, Optional, MarshalAs(UnmanagedType.LPTStr)] StringBuilder szValue, ref uint pcchValue); /// /// The MsiSourceListSetInfo function sets information about the source list for a product or patch in a specific context. /// /// /// The ProductCode or patch GUID of the product or patch. Use a null-terminated string. If the string is longer than 39 characters, /// the function fails and returns ERROR_INVALID_PARAMETER. This parameter cannot be NULL. /// /// /// /// This parameter can be a string SID that specifies the user account that contains the product or patch. The SID is not validated /// or resolved. An incorrect SID can return ERROR_UNKNOWN_PRODUCT or ERROR_UNKNOWN_PATCH. When referencing a machine /// context, szUserSID must be NULL and dwContext must be MSIINSTALLCONTEXT_MACHINE. /// /// /// /// Type of SID /// Meaning /// /// /// NULL /// /// NULL denotes the currently logged on user. When referencing the current user account, szUserSID can be NULL and dwContext can be /// MSIINSTALLCONTEXT_USERMANAGED or MSIINSTALLCONTEXT_USERUNMANAGED. /// /// /// /// User SID /// Specifies enumeration for a particular user in the system. An example of a user SID is "S-1-3-64-2415071341-1358098788-3127455600-2561". /// /// /// /// Note The special SID string "S-1-5-18" (system) cannot be used to enumerate products or patches installed as per-machine. /// Setting the SID value to "S-1-5-18" returns "ERROR_INVALID_PARAMETER". /// /// /// Note The special SID string "S-1-1-0" (everyone) should not be used. Setting the SID value to "S-1-1-0" fails and returns ERROR_INVALID_PARAM. /// /// /// /// /// This parameter specifies the context of the product or patch instance. This parameter can contain one of the following values. /// /// /// /// Type of context /// Meaning /// /// /// MSIINSTALLCONTEXT_USERMANAGED /// The product or patch instance exists in the per-user-managed context. /// /// /// MSIINSTALLCONTEXT_USERUNMANAGED /// The product or patch instance exists in the per-user-unmanaged context. /// /// /// MSIINSTALLCONTEXT_MACHINE /// The product or patch instance exists in the per-machine context. /// /// /// /// /// The dwOptions value specifies the meaning of szProductCodeOrPatchCode. /// /// If the property being set is "LastUsedSource", this parameter also specifies the type of source as network or URL. In this case, /// the dwOptions parameter must be a combination of one of the following MSISOURCETYPE_ constants and one of the following /// MSICODE_ constants. /// /// /// /// Flag /// Meaning /// /// /// MSISOURCETYPE_NETWORK /// The source is a network type. /// /// /// MSISOURCETYPE_URL /// The source is a URL type. /// /// /// MSICODE_PRODUCT /// szProductCodeOrPatchCode is a product code GUID. /// /// /// MSICODE_PATCH /// szProductCodeOrPatchCode is a patch code GUID. /// /// /// /// /// /// The parameter szProperty indicates the property value to set. Not all properties that can be retrieved through /// MsiSourceListGetInfo can be set via a call to MsiSourceListSetInfo. The szProperty value can be one of the following values. /// /// /// /// Name /// Meaning /// /// /// INSTALLPROPERTY_MEDIAPACKAGEPATH "MediaPackagePath" /// The path relative to the root of the installation media. /// /// /// INSTALLPROPERTY_DISKPROMPT "DiskPrompt" /// The prompt template used when prompting the user for installation media. /// /// /// INSTALLPROPERTY_LASTUSEDSOURCE "LastUsedSource" /// /// The most recently used source location for the product. If the source is not registered, the function calls /// MsiSourceListAddSourceEx to register it. On successful registration, the function sets the source as the LastUsedSource. /// /// /// /// INSTALLPROPERTY_PACKAGENAME "PackageName" /// The name of the Windows Installer package or patch package on the source. /// /// /// /// /// The new value of the property. No validation of the new value is performed. This value cannot be NULL. It can be an empty string. /// /// /// The MsiSourceListSetInfo function returns the following values. /// /// /// Value /// Meaning /// /// /// ERROR_ACCESS_DENIED /// The user does not have the ability to set the source list for the specified product. /// /// /// ERROR_BAD_CONFIGURATION /// The configuration data is corrupt. /// /// /// ERROR_INSTALL_SERVICE_FAILURE /// The Windows Installer service could not be accessed. /// /// /// ERROR_INVALID_PARAMETER /// An invalid parameter was passed to the function. /// /// /// ERROR_SUCCESS /// The property was set. /// /// /// ERROR_UNKNOWN_PATCH /// The patch was not found. /// /// /// ERROR_UNKNOWN_PRODUCT /// The product was not found. /// /// /// ERROR_UNKNOWN_PROPERTY /// The source property was not found. /// /// /// ERROR_FUNCTION_FAILED /// Unexpected internal failure. /// /// /// /// /// /// Administrators can modify the installation of a product or patch instance that exists under the machine context or under their /// own per-user context (managed or unmanaged.) They can modify the installation of a product or patch instance that exists under /// any user's per-user-managed context. Administrators cannot modify another user's installation of a product or patch instance /// that exists under that other user's per-user-unmanaged context. /// /// /// Non-administrators cannot modify the installation of a product or patch instance that exists under another user's per-user /// context (managed or unmanaged.) They can modify the installation of a product or patch instance that exists under their own /// per-user-unmanaged context. They can modify the installation of a product or patch instance under the machine context or their /// own per-user-managed context only if they are enabled to browse for a product or patch source. Users can be enabled to browse /// for sources by setting policy. For more information, see the DisableBrowse, AllowLockdownBrowse, and AlwaysInstallElevated policies. /// /// /// An exception to the above rule is setting "LastUsedSource" to one of the registered sources. If the source is already /// registered, a non-administrator can set "LastUsedSource" to their own installations (managed or non-managed) and per-machine /// installations, irrespective of policies. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msisourcelistsetinfoa UINT MsiSourceListSetInfoA( LPCSTR // szProductCodeOrPatchCode, LPCSTR szUserSid, MSIINSTALLCONTEXT dwContext, DWORD dwOptions, LPCSTR szProperty, LPCSTR szValue ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiSourceListSetInfoA")] public static extern Win32Error MsiSourceListSetInfo([MarshalAs(UnmanagedType.LPTStr)] string szProductCodeOrPatchCode, [Optional, MarshalAs(UnmanagedType.LPTStr)] string szUserSid, MSIINSTALLCONTEXT dwContext, uint dwOptions, [MarshalAs(UnmanagedType.LPTStr)] string szProperty, [MarshalAs(UnmanagedType.LPTStr)] string szValue); /// /// The MsiUseFeature function increments the usage count for a particular feature and indicates the installation state for /// that feature. This function should be used to indicate an application's intent to use a feature. /// /// Specifies the product code for the product that owns the feature to be used. /// Identifies the feature to be used. /// /// /// /// Value /// Meaning /// /// /// INSTALLSTATE_ABSENT /// The feature is not installed. /// /// /// INSTALLSTATE_ADVERTISED /// The feature is advertised /// /// /// INSTALLSTATE_BADCONFIG /// The configuration data is corrupt. /// /// /// INSTALLSTATE_INVALIDARG /// Invalid function argument. /// /// /// INSTALLSTATE_LOCAL /// The feature is locally installed and available for use. /// /// /// INSTALLSTATE_SOURCE /// The feature is installed from the source and available for use. /// /// /// INSTALLSTATE_UNKNOWN /// The feature is not published. /// /// /// /// /// The MsiUseFeature function should only be used on features known to be published. INSTALLSTATE_UNKNOWN indicates that the /// program is trying to use a feature that is not published. The application should determine whether the feature is published /// before calling MsiUseFeature by calling MsiQueryFeatureState or MsiEnumFeatures. The application should make these calls /// while it initializes. An application should only use features that are known to be published. /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msiusefeaturea INSTALLSTATE MsiUseFeatureA( LPCSTR szProduct, // LPCSTR szFeature ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiUseFeatureA")] public static extern INSTALLSTATE MsiUseFeature([MarshalAs(UnmanagedType.LPTStr)] string szProduct, [MarshalAs(UnmanagedType.LPTStr)] string szFeature); /// /// The MsiUseFeatureEx function increments the usage count for a particular feature and indicates the installation state for /// that feature. This function should be used to indicate an application's intent to use a feature. /// /// Specifies the product code for the product that owns the feature to be used. /// Identifies the feature to be used. /// /// This parameter can have the following value. /// /// /// Value /// Meaning /// /// /// INSTALLMODE_NODETECTION /// Return value indicates the installation state. /// /// /// /// Reserved for future use. This value must be set to 0. /// /// /// /// Value /// Meaning /// /// /// INSTALLSTATE_ABSENT /// The feature is not installed. /// /// /// INSTALLSTATE_ADVERTISED /// The feature is advertised /// /// /// INSTALLSTATE_LOCAL /// The feature is locally installed and available for use. /// /// /// INSTALLSTATE_SOURCE /// The feature is installed from the source and available for use. /// /// /// INSTALLSTATE_UNKNOWN /// The feature is not published. /// /// /// /// /// The MsiUseFeatureEx function should only be used on features known to be published. INSTALLSTATE_UNKNOWN indicates that /// the program is trying to use a feature that is not published. The application should determine whether the feature is published /// before calling MsiUseFeature by calling MsiQueryFeatureState or MsiEnumFeatures. The application should make these calls while /// it initializes. An application should only use features that are known to be published. /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msiusefeatureexa INSTALLSTATE MsiUseFeatureExA( LPCSTR szProduct, // LPCSTR szFeature, DWORD dwInstallMode, DWORD dwReserved ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiUseFeatureExA")] public static extern INSTALLSTATE MsiUseFeatureEx([MarshalAs(UnmanagedType.LPTStr)] string szProduct, [MarshalAs(UnmanagedType.LPTStr)] string szFeature, INSTALLMODE dwInstallMode, uint dwReserved = 0); /// The MsiVerifyPackage function verifies that the given file is an installation package. /// Specifies the path and file name of the package. /// /// /// /// Value /// Meaning /// /// /// ERROR_INSTALL_PACKAGE_INVALID /// The file is not a valid package. /// /// /// ERROR_INSTALL_PACKAGE_OPEN_FAILED /// The file could not be opened. /// /// /// ERROR_INVALID_PARAMETER /// The parameter is not valid. /// /// /// ERROR_SUCCESS /// The file is a package. /// /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msiverifypackagew UINT MsiVerifyPackageW( LPCWSTR szPackagePath ); [DllImport(Lib_Msi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("msi.h", MSDNShortId = "NF:msi.MsiVerifyPackageW")] public static extern Win32Error MsiVerifyPackage([MarshalAs(UnmanagedType.LPTStr)] string szPackagePath); } }