Re: VerQueryValue

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: Danny (NOSPAMFORdaniel_ahorn_at_yahoo.com)
Date: 01/26/05


Date: Wed, 26 Jan 2005 23:48:04 GMT

Thanks, Karl, I'll have a look.

In the meantime, I forgot to mention last time:

VB6 under W98.

Date: Wed, 26 Jan 2005 13:50:48 -0800
Name: "Karl E. Peterson" <karl@mvps.org>

>I don't see the problem immediately, but you might want to compare your code to that
>at http://vb.mvps.org/samples/FileInfo (which does work with this call).
>--
>[Microsoft Basic: 1976-2001, RIP]
>
>
>Danny wrote:
>> In the code below I'm trying to get File Version number and everything
>> works except the very last step: VerQueryValue (bRetCode returns
>> False, and both output variables are 0).
>>
>> I examined the string returned by GetFileVersionInfo and it looks
>> fine; FileVersion exists (see dump below).
>>
>> The only oddity is that the API Viewer had a small error in the
>> Declare; the Alias did not have an "A" at the end which I added.
>>
>> Thanks!
>>
>> --- declare ---
>>
>> Public Declare Function VerQueryValue Lib "version.dll" _
>> Alias "VerQueryValueA" ( _
>> pBlock As Any, _
>> ByVal lpSubBlock As String, _
>> ByVal lplpBuffer As Long, _
>> puLen As Long) _
>> As Long
>>
>> --- code ---
>>
>> Public Sub GetMAIDVersion()
>> Dim i As Long
>>
>> Dim dwVerInfoSize As Long
>> Dim lpVersion As Long
>> Dim dwVerHnd As Long
>> Dim puVersionLen As Long
>> Dim bRetCode As Boolean
>>
>> Dim szFileName As String
>> szFileName = App.Path & MAIDname
>>
>> dwVerHnd = 0
>>
>> dwVerInfoSize = GetFileVersionInfoSize(szFileName, dwVerHnd)
>>
>> If dwVerInfoSize > 0 Then
>> Dim lpstrVffInfo() As Byte
>> ReDim lpstrVffInfo(dwVerInfoSize)
>>
>> i = GetFileVersionInfo( _
>> szFileName, _
>> dwVerHnd, _
>> dwVerInfoSize, _
>> lpstrVffInfo(0))
>>
>> Dim FileVersion As String
>> FileVersion = "\\StringFileInfo\\040904E4\\FileVersion" & Chr(0)
>>
>> ' get file version
>> bRetCode = VerQueryValue( _
>> lpstrVffInfo(0), _
>> "\\StringFileInfo\\040904E4\\FileVersion", _
>> lpVersion, _
>> puVersionLen)
>> Stop
>>
>> End If
>> End Sub
>>
>> --- FileVersionInfo dump ---
>>
>> 00000000: E0 01 34 00 56 53 5F 56 45 52 53 49 4F 4E 5F 49
>> "..4.VS_VERSION_I"
>> 00000010: 4E 46 4F 00 BD 04 EF FE 00 00 01 00 00 00 01 00
>> "NFO............."
>> 00000020: C2 0B 00 00 00 00 04 00 00 00 00 00 3F 00 00 00
>> "............?..."
>> 00000030: 00 00 00 00 04 00 04 00 02 00 00 00 00 00 00 00
>> "................"
>> 00000040: 00 00 00 00 00 00 00 00 74 01 00 00 53 74 72 69
>> "........t...Stri"
>> 00000050: 6E 67 46 69 6C 65 49 6E 66 6F 00 00 60 01 00 00
>> "ngFileInfo..`..."
>> 00000060: 30 34 30 39 30 31 42 35 00 00 6E 00 24 00 12 00
>> "040901B5..n.$..."
>> 00000070: 43 6F 6D 6D 65 6E 74 73 00 00 66 00 4E 69 6B 6F
>> "Comments..f.Niko"
>> 00000080: 6E 20 53 63 61 6E 20 44 72 69 76 65 72 00 30 00 "n Scan
>> Driver.0."
>> 00000090: 24 00 12 00 43 6F 6D 70 61 6E 79 4E 61 6D 65 00
>> "$...CompanyName."
>> 000000A0: 4E 69 6B 6F 6E 20 43 6F 72 70 6F 72 61 74 69 6F "Nikon
>> Corporatio"
>> 000000B0: 6E 00 69 00 28 00 12 00 46 69 6C 65 44 65 73 63
>> "n.i.(...FileDesc"
>> 000000C0: 72 69 70 74 69 6F 6E 00 4E 69 6B 6F 6E 20 53 63
>> "ription.Nikon Sc"
>> 000000D0: 61 6E 20 44 72 69 76 65 72 00 43 00 20 00 0E 00 "an
>> Driver.C. ..."
>> 000000E0: 46 69 6C 65 56 65 72 73 69 6F 6E 00 31 2C 20 30
>> "FileVersion.1, 0"
>> 000000F0: 2C 20 30 2C 20 33 30 31 30 00 6F 00 1C 00 07 00 ", 0,
>> 3010.o....."
>> 00000100: 49 6E 74 65 72 6E 61 6C 4E 61 6D 65 00 00 74 00
>> "InternalName..t."
>> 00000110: 4C 53 35 30 30 30 00 00 44 00 2D 00 4C 65 67 61
>> "LS5000..D.-.Lega"
>> 00000120: 6C 43 6F 70 79 72 69 67 68 74 00 00 43 6F 70 79
>> "lCopyright..Copy"
>> 00000130: 72 69 67 68 74 20 28 43 29 20 4E 69 6B 6F 6E 20 "right
>> (C) Nikon "
>> 00000140: 43 6F 72 70 6F 72 61 74 69 6F 6E 2E 20 31 39 39
>> "Corporation. 199"
>> 00000150: 35 20 2D 20 32 30 30 33 00 00 69 00 24 00 0B 00 "5 -
>> 2003..i.$..."
>> 00000160: 4F 72 69 67 69 6E 61 6C 46 69 6C 65 6E 61 6D 65
>> "OriginalFilename"
>> 00000170: 00 00 56 00 4C 53 35 30 30 30 2E 4D 44 33 00 00
>> "..V.LS5000.MD3.."
>> 00000180: 1C 00 0B 00 50 72 6F 64 75 63 74 4E 61 6D 65 00
>> "....ProductName."
>> 00000190: 4E 69 6B 6F 6E 20 53 63 61 6E 00 00 20 00 0B 00 "Nikon
>> Scan.. ..."
>> 000001A0: 50 72 6F 64 75 63 74 56 65 72 73 69 6F 6E 00 00
>> "ProductVersion.."
>> 000001B0: 34 2C 20 30 2C 20 30 2C 20 30 00 00 24 00 00 00 "4, 0,
>> 0, 0..$..."
>> 000001C0: 56 61 72 46 69 6C 65 49 6E 66 6F 00 14 00 04 00
>> "VarFileInfo....."
>> 000001D0: 54 72 61 6E 73 6C 61 74 69 6F 6E 00 09 04 B5 01
>> "Translation....."
>> 000001E0: 43 00 6F 00 70 00 79 00 72 00 69 00 67 00 68 00
>> "C.o.p.y.r.i.g.h."
>> 000001F0: 74 00 00 00 43 00 6F 00 70 00 79 00 72 00 69 00
>> "t...C.o.p.y.r.i."
>> 00000200: 67 00 68 00 74 00 20 00 28 00 43 00 29 00 20 00 "g.h.t.
>> .(.C.). ."
>> 00000210: 4E 00 69 00 6B 00 6F 00 6E 00 20 00 43 00 6F 00
>> "N.i.k.o.n. .C.o."
>> 00000220: 72 00 70 00 6F 00 72 00 61 00 74 00 69 00 6F 00
>> "r.p.o.r.a.t.i.o."
>> 00000230: 6E 00 2E 00 20 00 31 00 39 00 39 00 35 00 20 00 "n...
>> 1.9.9.5. ."
>> 00000240: 2D 00 20 00 32 00 30 00 30 00 33 00 00 00 00 00 "-.
>> 2.0.0.3....."
>> 00000250: 3E 00 0B 00 01 00 4F 00 72 00 69 00 67 00 69 00
>> ">.....O.r.i.g.i."
>> 00000260: 6E 00 61 00 6C 00 46 00 69 00 6C 00 65 00 6E 00
>> "n.a.l.F.i.l.e.n."
>> 00000270: 61 00 6D 00 65 00 00 00 4C 00 53 00 35 00 30 00
>> "a.m.e...L.S.5.0."
>> 00000280: 30 00 30 00 2E 00 4D 00 44 00 33 00 00 00 00 00
>> "0.0...M.D.3....."
>> 00000290: 36 00 0B 00 01 00 50 00 72 00 6F 00 64 00 75 00
>> "6.....P.r.o.d.u."
>> 000002A0: 63 00 74 00 4E 00 61 00 6D 00 65 00 00 00 00 00
>> "c.t.N.a.m.e....."
>> 000002B0: 4E 00 69 00 6B 00 6F 00 6E 00 20 00 53 00 63 00
>> "N.i.k.o.n. .S.c."
>> 000002C0: 61 00 6E 00 00 00 00 00 3A 00 0B 00 01 00 50 00
>> "a.n.....:.....P."
>> 000002D0: 72 00 6F 00 64 00 75 00 63 00 74 00 56 00 65 00
>> "r.o.d.u.c.t.V.e."
>> 000002E0: 72 00 73 00 69 00 6F 00 6E 00 00 00 34 00 2C 00
>> "r.s.i.o.n...4.,."
>> 000002F0: 20 00 30 00 2C 00 20 00 30 00 2C 00 20 00 30 00 " .0.,.
>> .0.,. .0."
>> 00000300: 00 00 00 00 44 00 00 00 01 00 56 00 61 00 72 00
>> "....D.....V.a.r."
>> 00000310: 46 00 69 00 6C 00 65 00 49 00 6E 00 66 00 6F 00
>> "F.i.l.e.I.n.f.o."
>> 00000320: 00 00 00 00 24 00 04 00 00 00 54 00 72 00 61 00
>> "....$.....T.r.a."
>> 00000330: 6E 00 73 00 6C 00 61 00 74 00 69 00 6F 00 6E 00
>> "n.s.l.a.t.i.o.n."
>> 00000340: 00 00 00 00 09 04 B5 01
>> "........"
>>
>> --- end ---
>>
>> Danny
>>
>> (You guessed it! ;o) Remove NOSPAMFOR before emailing.)
>
>
>

Danny

(You guessed it! ;o) Remove NOSPAMFOR before emailing.)



Relevant Pages

  • Re: VerQueryValue
    ... >Danny wrote: ... >> Public Sub GetMAIDVersion() ... >> Dim dwVerInfoSize As Long ... >> Dim szFileName As String ...
    (microsoft.public.vb.winapi)
  • Re: VerQueryValue
    ... >Danny wrote: ... >> Public Sub GetMAIDVersion() ... >> Dim dwVerInfoSize As Long ... >> Dim szFileName As String ...
    (microsoft.public.vb.general.discussion)
  • Re: VerQueryValue
    ... Which means API Viewer not only had the Alias wrong but the whole ... >Danny wrote: ... >> Dim dwVerInfoSize As Long ... >> Dim szFileName As String ...
    (microsoft.public.vb.general.discussion)
  • Re: VerQueryValue
    ... Which means API Viewer not only had the Alias wrong but the whole ... >Danny wrote: ... >> Dim dwVerInfoSize As Long ... >> Dim szFileName As String ...
    (microsoft.public.vb.winapi)
  • Re: VerQueryValue
    ... Which means API Viewer not only had the Alias wrong but the whole ... >Danny wrote: ... >> Dim dwVerInfoSize As Long ... >> Dim szFileName As String ...
    (microsoft.public.vb.syntax)