![]() |
|
![]() |
Windows Installer Basics: VB Declarations |
This is basic documentation badly missing from the MS doco...
Note that generally I use VBSCRIPT wherever possible as its much faster and easier to build but not everything can be done in script and you may need to work around script alerts.
To work out the values of constants, SDK include files such as "MSI.H" and "MsiQuery.H" can be examined (of course again it would be better if they were documented).
I have added tried and tested declarations here, let me know if you have others:
Public Declare Function MsiCloseAllHandles Lib "msi.dll" () As Integer
Public Declare Function MsiCloseHandle Lib "msi.dll" (ByVal hAny As Long) As Integer
Public Declare Function MsiDatabaseCommit Lib "msi.dll" (ByVal hDatabase As Long) As Integer
Public Declare Function MsiDatabaseIsTablePersistent Lib "msi.dll" Alias "MsiDatabaseIsTablePersistentA" ( ByVal hDatabase As Long, ByVal szTableName As String ) As Long
public Declare Function MsiDatabaseMerge Lib "msi.dll" Alias "MsiDatabaseMergeA" ( _ ByVal hDatabaseInTo As Long, _ ByVal hDatabaseFrom As Long, _ ByVal MsiName As String _ ) As Integer
Public Declare Function MsiDatabaseOpenView Lib "msi.dll" Alias "MsiDatabaseOpenViewA" ( _ ByVal hDatabase As Long, _ ByVal szSqlQuery As String, _ ByRef hView As Long _ ) As Integer
public Declare Function MsiDoAction Lib "msi.dll" Alias "MsiDoActionA" ( _ ByVal hInstall As Long, _ ByVal szAction As String _ ) As Integer
public Declare Function MsiEnableLog Lib "msi.dll" Alias "MsiEnableLogA" ( _ ByVal dwLogMode As Long, _ ByVal szLogFile As String, _ ByVal dwLogAttributes As Long _ ) As Integer
Public Declare Function MsiGetDatabaseState Lib "msi.dll" (ByVal hDatabase As Long) As Long
public Declare Function MsiInstallProduct Lib "msi.dll" Alias "MsiInstallProductA" ( _ ByVal MsiName As String, _ ByVal CmdLine As String _ ) As Integer
'--- 2nd parameter is a perstance mode (2=Direct etc) ---- Public Declare Function MsiOpenDatabase Lib "msi.dll" Alias "MsiOpenDatabaseA"( _ ByVal szFileName As String, _ ByVal iPersistMode As Integer, _ ByRef hDatabase As Long _ ) As Integer '--- 2nd parameter is a file name ---- Public Declare Function MsiOpenDatabaseFN Lib "msi.dll" Alias "MsiOpenDatabaseA"( _ ByVal szFileName As String, _ ByVal szNewFileName As String, _ ByRef hDatabase As Long _ ) As Integer
public Declare Function MsiOpenPackage Lib "msi.dll" Alias "MsiOpenPackageA" ( _ ByVal szFileName As String, _ ByRef hProduct As Long _ ) As Integer
public Declare Function MsiSetInternalUI Lib "msi.dll" ( _ ByVal dwMessageFilter As Long, _ ByRef puiHandler As Long _ ) As Integer
public Declare Function MsiSetExternalUI Lib "msi.dll" Alias "MsiSetExternalUIA" ( _ ByVal puiHandler As Long, _ ByVal dwMessageFilter As Long, _ ByVal pvContext As String _ ) As Long
Public Declare Function MsiViewExecute Lib "msi.dll" ( _ ByVal hView As Long, _ ByVal hRecord As Long _ ) As Integer
The above have been used with some degree of success in at least one program I have compiled and tested. There is no guarantee that they are 100% correct, if you know of a problem please let me know and I will update the list. If you can supply a very small working program as an example then I can add this to the doco.
Functions such as "MsiOpenDatabase()" show that there is not always one correct declaration and of course in the above I have not used the "W" versions (just the "A" for ANSI ones).
![]() ![]() |
| ![]() ![]() |