public bool MsiAddInternalBinaryStream(IntPtr hDatabase, string cabname, string cabId, string cabfullpath) { //for info on the _Streams table, see MSDN: // http://msdn.microsoft.com/en-us/library/aa372919(VS.85).aspx Dictionary <int, Dictionary <string, string> > tableRecords = new Dictionary <int, Dictionary <string, string> >(); Dictionary <string, string> record = new Dictionary <string, string>(); uint retVal = CwMsiWin32.ERROR_SUCCESS; string selectQuery = "SELECT * FROM `_Streams`"; IntPtr hView = IntPtr.Zero; IntPtr hRecord = IntPtr.Zero; //open the database view retVal = CwMsiWin32.MsiDatabaseOpenViewW(hDatabase, selectQuery, out hView); MsiThrowOnFailure(hDatabase, retVal, "MsiDatabaseOpenViewW()"); //create a new record hRecord = CwMsiWin32.MsiCreateRecord(2); //2 fields: Name and Data //set the Name column of the _Streams table to the Cabinet name (file name on disk) retVal = CwMsiWin32.MsiRecordSetStringW(hRecord, 1, cabId); MsiThrowOnFailure(hDatabase, retVal, "MsiRecordSetStringW: Failed to set the Name column in the _Streams table to '" + cabname + "'"); //set the Data column of the _Streams table to the Cabinet name (full file path location on disk) retVal = CwMsiWin32.MsiRecordSetStreamW(hRecord, 2, cabfullpath); MsiThrowOnFailure(hDatabase, retVal, "MsiRecordSetStream: Failed to set the Data column in the _Streams table to '" + cabfullpath + "'"); //apply the update retVal = CwMsiWin32.MsiViewModify(hView, CwMsiWin32.MSIMODIFY_INSERT, hRecord); MsiThrowOnFailure(hDatabase, retVal, "MsiViewModify: Failed to apply update to CAB '" + cabId + "'"); //commit database retVal = CwMsiWin32.MsiDatabaseCommit(hDatabase); MsiThrowOnFailure(hDatabase, retVal, "MsiDatabaseCommit: Could not commit msi db."); CwMsiWin32.MsiCloseHandle(hView); CwMsiWin32.MsiCloseHandle(hRecord); return(true); }