Craig Dahlinger
2004-05-13 15:36:09 UTC
Hey all, I am very new to MSI, but I am trying to do something very simple.
I want to extract the files out of an MSI and get FileVersionInfo oneach
file. I am able to open the database, create view, and get file names for
example, but where are the actual files being stored to extract. I am
assuming they are in binary format so I would have to do a binary
extraction, but I cannot find any examples on the internet or anywhere
please help...
Here is the C# code I got so far:
public static bool ExtractMSIInfo(string MSIFile, int iHotFixId)
{
WindowsInstaller.Installer oInstaller;
oInstaller = (WindowsInstaller.Installer)new
WindowsInstaller.InstallerClass();
WindowsInstaller.Database oDataBase = null;
WindowsInstaller.View oView = null;
try
{
//open database
oDataBase =
oInstaller.OpenDatabase(MSIFile,WindowsInstaller.MsiOpenDatabaseMode.msiOpen
DatabaseModeReadOnly);
//create view
oView = oDataBase.OpenView("SELECT FileName FROM File");
//create record holder
WindowsInstaller.Record oRecord = null;;
//execute query
oView.Execute(oRecord);
//get record
oRecord = oView.Fetch();
do
{
int columnCount = oRecord.FieldCount;
//loop through colums in record
for(int i=1;i<=columnCount;i++)
{
System.Diagnostics.Debug.WriteLine(oRecord.get_StringData(i));
}
oRecord = oView.Fetch();
}while(!(oRecord == null));
//close view
oView.Close();
//flush database buffers as stated in SDK Doc
oDataBase.Commit();
return true;
}
catch(Exception ex)
{
I3NetTrace.Trace_Error(nTopic,ex.Message + ex.StackTrace);
throw;
}
finally
{
//release all, when all go out of scrope, file is released
oView = null;
oDataBase = null;
oInstaller = null;
//as a precaution
}
}
I want to extract the files out of an MSI and get FileVersionInfo oneach
file. I am able to open the database, create view, and get file names for
example, but where are the actual files being stored to extract. I am
assuming they are in binary format so I would have to do a binary
extraction, but I cannot find any examples on the internet or anywhere
please help...
Here is the C# code I got so far:
public static bool ExtractMSIInfo(string MSIFile, int iHotFixId)
{
WindowsInstaller.Installer oInstaller;
oInstaller = (WindowsInstaller.Installer)new
WindowsInstaller.InstallerClass();
WindowsInstaller.Database oDataBase = null;
WindowsInstaller.View oView = null;
try
{
//open database
oDataBase =
oInstaller.OpenDatabase(MSIFile,WindowsInstaller.MsiOpenDatabaseMode.msiOpen
DatabaseModeReadOnly);
//create view
oView = oDataBase.OpenView("SELECT FileName FROM File");
//create record holder
WindowsInstaller.Record oRecord = null;;
//execute query
oView.Execute(oRecord);
//get record
oRecord = oView.Fetch();
do
{
int columnCount = oRecord.FieldCount;
//loop through colums in record
for(int i=1;i<=columnCount;i++)
{
System.Diagnostics.Debug.WriteLine(oRecord.get_StringData(i));
}
oRecord = oView.Fetch();
}while(!(oRecord == null));
//close view
oView.Close();
//flush database buffers as stated in SDK Doc
oDataBase.Commit();
return true;
}
catch(Exception ex)
{
I3NetTrace.Trace_Error(nTopic,ex.Message + ex.StackTrace);
throw;
}
finally
{
//release all, when all go out of scrope, file is released
oView = null;
oDataBase = null;
oInstaller = null;
//as a precaution
}
}