MSI.RecordSetStream |
|
|
|
MSI.RecordSetStream |
|
|
|
|
||
OverviewExamples
boolean MSI.RecordSetStream ( |
boolean ResetStream = true ) |
hDatabase = MSI.GetActiveDatabase(_hInstall);
if (hDatabase ~= 0) then
strQuery = "SELECT * FROM `_Streams`";
hView = MSI.DatabaseOpenView(hDatabase, strQuery);
if (hView ~= 0) then
bExecuteResult = MSI.ViewExecute(hView, 0);
if (bExecuteResult) then
-- Create a new record for our icon stream
hNewRecord = MSI.CreateRecord(2);
MSI.RecordSetString(hNewRecord, 1, "icon_new");
-- Do not Reset Stream for new records
MSI.RecordSetStream(hNewRecord, 2, "C:\\extracted\\MSIFactory.ico", false);
-- Add to the database
bSuccess = MSI.ViewModify(hView, MSIMODIFY_INSERT, hNewRecord);
if (not bSuccess) then
Dialog.Message("Error", "Failed to insert icon");
end
MSI.CloseHandle(hNewRecord);
else
Dialog.Message("Execute Failed", "Execute Failed.");
end
MSI.ViewClose(hView);
MSI.CloseHandle(hView);
else
Dialog.Message("View Error","View Failed.");
end
-- Try to write out the icdon
strQuery = "SELECT * FROM `_Streams` WHERE `Name`='icon_new'";
hView = MSI.DatabaseOpenView(hDatabase, strQuery);
if (hView ~= 0) then
bExecuteResult = MSI.ViewExecute(hView, 0);
if (bExecuteResult) then
hRecord = MSI.ViewFetch(hView);
if (hRecord ~= 0) then
-- Read the Icon binary stream
strStream = MSI.RecordReadStream(hRecord, 2);
-- Did the MSI.RecordReadStream() work?
if (strStream ~= nil) then
-- Create a new binary file for writing
hFile, strError = io.open("C:\\my_new_icon.ico", "wb");
if (hFile ~= nil) then
-- Write the binary data to disk
hFile:write(strStream);
-- Close the file
hFile:close();
else
-- Error
Dialog.Message("Error", "Failed to write file:\r\n"..strError)
end
end
else
Dialog.Message("Error", "View Fetch Failed.");
end
MSI.CloseHandle(hRecord);
else
Dialog.Message("Execute Failed", "Execute Failed.");
end
MSI.ViewClose(hView);
MSI.CloseHandle(hView);
else
Dialog.Message("View Error","View Failed.");
end
MSI.CloseHandle(hDatabase);
end
Creates a new entry containing an icon file in the _Streams table, and reads it back as a test.
See also: Related Actions
Learn More: Indigo Rose Software - MSI Factory - Buy Now - Contact Us