I am trying to get file version info. When I run the following code, VB
closes (No error, nothing .. it just goes away!) when I run the last line.
Any comments???
Otherwise, any other way of getting the file info of a file that is not
running?
Private Declare Function GetFileVersionInfo Lib "version.dll" Alias
"GetFileVersionInfoA" (ByVal lptstrFilename As String, ByVal dwHandle As
Long, ByVal dwLen As Long, lpData As Any) As Long
Private Declare Function GetFileVersionInfoSize Lib "version.dll" Alias
"GetFileVersionInfoSizeA" (ByVal lptstrFilename As String, lpdwHandle As
Long) As Long
l_sFilename = (myfilename)
l_lVersionSize = GetFileVersionInfoSize(l_sFileName, l_lHandle) ' this
returns 1201 for my test file
l_sBuffer = String$(l_lVersionSize, Chr$(0))
l_lBufferLen = Len(l_sBuffer) 'obviously, this is 1201
l_lRet = GetFileVersionInfo(l_sFileName, l_lHandle, l_lBufferLen,
l_sBuffer)
Roger
R.Wieser - 31 Oct 2003 13:38 GMT
Roger <rogor@mweb.co.za> schreef in berichtnieuws
bntgov$kfv$1@ctb-nnrp2.saix.net...
Hello Roger,
> I am trying to get file version info. When I run the following code, VB
> closes (No error, nothing .. it just goes away!) when I run the last line.
[quoted text clipped - 8 lines]
> ByVal dwLen As Long, _
> lpData As Any _
--------------^^^ (1)
>) As Long
> Private Declare Function GetFileVersionInfoSize Lib "version.dll" _
> Alias "GetFileVersionInfoSizeA" ( _
[quoted text clipped - 10 lines]
> l_lRet = GetFileVersionInfo(l_sFileName, l_lHandle, _
> l_lBufferLen, l_sBuffer)
------------------^^^^^^^ (2)
You're defining "as any" (1), and are going to supply it with a string (2).
You are aware that strings should be transferred "by value" ?
Two options : change (1) to "By Val sBuffer as string", *or* change (2) to
"byval l_sBuffer". My preferred change would be the first, as it make's me
impossible to mistakingly forget the "by val" at (2) :-)
Regards,
Rudy Wieser