PDA

View Full Version : Getting the file version of a DLL about to be installed?



MHolmes
12-14-2004, 10:06 AM
I need to get the file version of a DLL that is about to be installed in to the GAC. I know I can use the VerGetFileVersion() function to get the version of a DLL, but how do I get this before the component is installed? I obviously can't read it after, as the DLL will be in the GAC.

I have looked in to reading the file from SRCDIR, but the only thing in SRCDIR are the MSI's, they are not uncompressed, meaning no directory structure exists to read the files from. Is there some other way to get this information, or do I have to install the DLL twice, once in the GAC and once as a support file to read its version from?

Perucho
12-15-2004, 10:01 AM
OnInstallingFile()


Open InstallScript project
go to "Installation Designer"
go to "Behavior and Logic"
go to "InstallScript"
on top of the code editor, go to "Initialization"
click on the down arrow to display the drop-down list
and select "Move Data"
on the right select "OnInstallingFile()"




//---------------------------------------------------------------------------
// OnInstallingFile
//
// The OnInstallingFile event is called when a file is about to be installed
// as a result of FeatureTransferData or FeatureMoveData.
//
// szFile will contain the full path of file about to be installed.
//---------------------------------------------------------------------------
function OnInstallingFile(szFile)
begin

// do your stuff here...
MessageBox(szFile, INFORMATION);

end;

There are many functions/events available, look for them:

under "Move Data"
OnInstallingFile()
OnInstalledFile()
OnUninstallingFile()
OnUninstalledFile()
.
.
.

under "Miscellaneous"
OnFileError()
.
.
.

MHolmes
12-15-2004, 10:53 AM
Wierd, I don't see any of those events. I am using an InstallScript MSI project...are those events only available on pure InstallScript projects?

RobertDickau
12-15-2004, 10:59 AM
Right, the OnInstallingFile event is available only for pure InstallScript; on MSI-based projects, file transfer is handled by the InstallFiles action, which is treated as a single operation.

If you want it badly enough, you could access the File table of your MSI database at run time with a custom action, as described in this InstallShield newsletter article: http://www.installshield.com/news/newsletter/0302-articles/msiaccess.asp.

MHolmes
12-15-2004, 11:04 AM
Looking at the 'File' table, the 'version' column is empty for all of the files in my installation (despite the fact that they do have a File Version if you look at their properties in Windows Explorer). Is this information not populated until runtime?

RobertDickau
12-15-2004, 11:05 AM
It's not populated until build time; are you looking at your ISM file or your MSI file?

MHolmes
12-15-2004, 11:09 AM
The ISM :) I will look at the MSI instead.

Thanks for the info!