Note: I've searched the various links to get information at one place. I've not checked the contents for validation. So I'm not responsible for any issue found related to the contents specified in the blog. Please use contents at own risk.
The api directory function of Msi - MsiSetTargetPath can be used to set the target path of the product to be installed. The complete syntax declaration of the api is given below:
MsiSetTargetPath:
Declare Function MsiSetTargetPath lib "MSI" (ByRef hInstall As MSIHANDLE, ByVal szFolder As String, ByVal szFolderPath As String) As LongThis function Sets the full target path for a directory listed in the Directory table.
Parameters
- hInstall [in] Handle to the installation provided to a DLL custom action or obtained
- through MsiOpenPackage, MsiOpenPackageEx, or
- MsiOpenProduct.
- szFolder [in] Specifies the folder identifier. This is a primary key in the Directory table.
- szFolderPath [in] Specifies the full path for the folder, ending in a directory separator.
Return Value
The MsiSetTargetPath function returns the following values:
- ERROR_DIRECTORY The directory specified was not found in the Directory table.
- ERROR_INVALID_HANDLE An invalid or inactive handle was supplied.
- ERROR_INVALID_PARAMETER An invalid parameter was passed to the function.
- ERROR_SUCCESS The function succeeded.
The Directory table specifies the directory layout for the product. Each row of the table indicates a directory both at the source and the target.
The Directory table has the following columns.
Column | Type | Key | Nullable |
---|---|---|---|
Directory | Identifier | Y | N |
Directory_Parent | Identifier | N | Y |
DefaultDir | DefaultDir | N | N |
Before using MsiSetTargetPath function, check the product state to ensure that nothing of the product was installed yet.
The installer sets the ProductState property to the installation state for the product at initialization. This property is set to one of the following INSTALLSTATE data types returned by MsiQueryProductState.
use the function MsiQueryProductState for this purpose.
MsiQueryProductState Function
Declare Function MsiQueryProductState lib "MSI" (ByVal szProduct As String) As INSTALLSTATE
Parameters
- szProduct [in] Specifies the product code that identifies the product to be queried.
Return Value
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. |
MsiOpenProduct
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.
Declare Function MsiOpenProduct lib "MSI" (ByVal szProduct As String, ByRef hProduct As MSIHANDLE) As Long
Parameters
- szProduct [in] Specifies the product code of the product to be opened.
- hProduct [out] Pointer to a variable that receives the product handle.
Return Value
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. |
MsiCloseHandle
Closes a database, view, or record handle.
Declare Function MsiCloseHandle lib "MSI" (ByRef hAny As MSIHANDLE) As Long
- hAny [in] Specifies any open installation handle.
Return Value
Value | Meaning |
---|---|
ERROR_INVALID_HANDLE | An invalid handle was passed to the function. |
ERROR_SUCCESS | The function succeeded. |
Related Studies:
1. Managed Applications
2. Microsoft Installer: MSI
3. msiblogger
No comments:
Post a Comment