WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

How To
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Msi Get File Version


Question:

Does anyone know a quick and easy way of querying the msi database (within an msi file) to get the version number? I am hoping for something OLE or DLLCall like.

I found this:

MsiGetFileVersion( LPCTSTR szFilePath, LPTSTR lpVersionBuf, DWORD* pcchVersionBuf, LPTSTR lpLangBuf, DWORD* pcchLangBuf ); 
http://msdn.microsoft.com/library/en-us/msi/setup/msigetfileversion.asp

I just need help with the translation to the winbatch DLLCall function MSI.dll is the dll involved.


szFilePath = "C:\WINDOWS\Cache\Adobe Reader 6.0\ENUBIG\adobe reader 6.0.msi"
lpVersionBuf = BinaryAlloc(1024)
pcchVersionBuf = BinaryAlloc(4)
BinaryPoke4(pcchVersionBuf, 0,1024)
dllname = StrCat(DirWindows(1),"Msi.dll")
ERROR_SUCCESS = 0
ERROR_FILE_INVALID = 1006
ret = DllCall( dllname, long:"MsiGetFileVersionA" , lpstr:szFilePath, lpbinary:lpVersionBuf, lpbinary:pcchVersionBuf, long:0, long:0 )
If ret == ERROR_SUCCESS
   ver = BinaryPeekStr(lpVersionBuf, 0, BinaryEodGet(lpVersionBuf))
   Message("Version",ver)
Else
   If ret == ERROR_FILE_INVALID
      Message("MsiGetFileVersionA Error","File does not contain version information.")
   Else
      Message("MsiGetFileVersionA Error",ret)
   EndIf
EndIf
BinaryFree( pcchVersionBuf )
BinaryFree( lpVersionBuf )

Article ID:   W17016
File Created: 2007:07:03:14:27:38
Last Updated: 2007:07:03:14:27:38