🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #10348

Re: Problems with VerQueryValue()

#10348
From: Remy Lebeau (TeamB)
Date: Sat, 17 Apr 2004 20:23
35 lines
2057 bytes
"JT" <nobody@hotmail.com> wrote in message
news:40811567$1@newsgroups.borland.com...


>             BOOL bRet = ::GetFileVersionInfo(FilePath,
>                                              (DWORD)dwVerHnd,
>                                              (DWORD)dwVerInfoSize,
>                                              (LPVOID)pVersionInfo);

You don't need to cast:

    BOOL bRet = ::GetFileVersionInfo(FilePath, dwVerHnd, dwVerInfoSize,
pVersionInfo);

>                 bRet = ::VerQueryValue(pVersionInfo,
"\\StringFileInfo\\040904b0\FileVersion",
>                          (LPVOID*)&szVer, &uVerLength);

You are missing a backslash on the "FileVersion" portion of the string:

    bRet = ::VerQueryValue(pVersionInfo,
"\\StringFileInfo\\040904b0\\FileVersion", (LPVOID*)&szVer, &uVerLength);

>             delete pVersionInfo;

You allocated the memory using 'new[]', but you are freeing it with
'delete'.  You must use 'delete[]' instead, otherwise you will have
undefined behavior in your program from that point on as the memory is freed
incorrectly:

    delete[] pVersionInfo;


Gambit
Technical Details
Message-ID: <408193be@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <40811567$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,fc037e182c66e00f
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2004-04-17 13:39:29 PST
From: "Remy Lebeau \(TeamB\)" <gambit47.no.spam@no.spam.yahoo.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <40811567$1@newsgroups.borland.com>
Subject: Re: Problems with VerQueryValue()
Date: Sat, 17 Apr 2004 13:23:30 -0700
Lines: 37
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 67.22.138.253
Message-ID: <408193be@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1082233790 67.22.138.253 (17 Apr 2004 13:29:50 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail