Does anyone have source code (doesn't matter what language) for adding records to the Binary table? I have seen code that modifies the Data field to a new stream, but I want to add new records programmatically.
This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.

Source code for adding records to Binary table
Started by
bsa99
, Jul 12 2002 18:58
1 reply to this topic
Posted 23 July 2002 - 20:25
Here is what I wrote, I hope it helps.
Public Function AddFilesToStream(ByVal sDatabaseFile As String, _
ByVal sFolder As String, ByVal sFileName As String, _
ByVal sStreamName As String) As Boolean
Const sModule As String = "AddFilesToStream::"
On Error GoTo eh
Dim oInstaller As WindowsInstaller.Installer
Set oInstaller = CreateObject("WindowsInstaller.Installer")
Dim oDatabase As WindowsInstaller.Database
Set oDatabase = oInstaller.OpenDatabase(sDatabaseFile, _
msiOpenDatabaseModeTransact)
Dim lUpdateMode As Long
lUpdateMode = msiViewModifyAssign
Dim sSQLQuery As String
sSQLQuery = "SELECT * FROM Binary"
Dim oView As WindowsInstaller.View
Set oView = oDatabase.OpenView(sSQLQuery)
oView.Execute
Dim oRecord As WindowsInstaller.Record
Set oRecord = oInstaller.CreateRecord(2)
oRecord.StringData(1) = sStreamName
oRecord.SetStream 2, Helper.AddSlash(sFolder) & sFileName
oView.Modify msiViewModifyInsert, oRecord
oDatabase.Commit
Set oRecord = Nothing
Set oView = Nothing
Set oDatabase = Nothing
Set oInstaller = Nothing
AddFilesToStream = True
Exit Function
eh:
If Err.Number = 91 Then
Else
If Err.Number = -2147467259 Then
AddFilesToStream = False
Err.Raise Err.Number, sModule & Err.Source, "FileName """ & _
sFileName & """ failed in database " & _
sDatabaseFile & "."
Else
With Err
.Raise .Number, sModule & .Source, .Description
End With
End If
End If
End Function
Public Function AddSlash(ByVal sDirectory As String) As String
Const sModule As String = "AddSlash::"
On Error GoTo eh
AddSlash = IIf(Right(sDirectory, 1) <> "\", sDirectory & "\", sDirectory)
Exit Function
eh:
With Err
.Raise .Number, m_sModule & sModule & .Source, .Description
End With
End Function
Hope this is what you need,
Ken
Public Function AddFilesToStream(ByVal sDatabaseFile As String, _
ByVal sFolder As String, ByVal sFileName As String, _
ByVal sStreamName As String) As Boolean
Const sModule As String = "AddFilesToStream::"
On Error GoTo eh
Dim oInstaller As WindowsInstaller.Installer
Set oInstaller = CreateObject("WindowsInstaller.Installer")
Dim oDatabase As WindowsInstaller.Database
Set oDatabase = oInstaller.OpenDatabase(sDatabaseFile, _
msiOpenDatabaseModeTransact)
Dim lUpdateMode As Long
lUpdateMode = msiViewModifyAssign
Dim sSQLQuery As String
sSQLQuery = "SELECT * FROM Binary"
Dim oView As WindowsInstaller.View
Set oView = oDatabase.OpenView(sSQLQuery)
oView.Execute
Dim oRecord As WindowsInstaller.Record
Set oRecord = oInstaller.CreateRecord(2)
oRecord.StringData(1) = sStreamName
oRecord.SetStream 2, Helper.AddSlash(sFolder) & sFileName
oView.Modify msiViewModifyInsert, oRecord
oDatabase.Commit
Set oRecord = Nothing
Set oView = Nothing
Set oDatabase = Nothing
Set oInstaller = Nothing
AddFilesToStream = True
Exit Function
eh:
If Err.Number = 91 Then
Else
If Err.Number = -2147467259 Then
AddFilesToStream = False
Err.Raise Err.Number, sModule & Err.Source, "FileName """ & _
sFileName & """ failed in database " & _
sDatabaseFile & "."
Else
With Err
.Raise .Number, sModule & .Source, .Description
End With
End If
End If
End Function
Public Function AddSlash(ByVal sDirectory As String) As String
Const sModule As String = "AddSlash::"
On Error GoTo eh
AddSlash = IIf(Right(sDirectory, 1) <> "\", sDirectory & "\", sDirectory)
Exit Function
eh:
With Err
.Raise .Number, m_sModule & sModule & .Source, .Description
End With
End Function
Hope this is what you need,
Ken