title: Get File Version for Delphi XE2 and later
body: <p>I'm updating a program to Delphi XE7 from Delphi 2010.  The code shown below has stopped working due I think to the need to adapt for unicode and to use GetFileVersionInfoW instead of GetFileVersionInfoSize.</p>
  
  <p>Has anyone developed a more up-to-date version of the function I was using shown below?  I can't find any examples so far on the web and I'm afraid that low level windows programming is a bit beyond me.</p>
  
  <p>Thanks for any help!</p>
  
  <p>Old Code Below No Longer works on Delphi XE2 and later: just returns 1.0.0.0</p>
  
  <pre><code>procedure GetBuildInfo(var V1, V2, V3, V4: Word);
  {From Steve Schafer }
  var
    VerInfoSize: DWORD;
    VerInfo: pointer;
    VerValueSize: DWORD;
    VerValue: PVSFixedFileInfo;
    Dummy: DWORD;
  
  begin
    VerInfoSize := GetFileVersionInfoSize(PChar(ParamStr(0)), Dummy);
    GetMem(VerInfo, VerInfoSize);
    GetFileVersionInfo(PChar(ParamStr(0)), 0, VerInfoSize, VerInfo);
    VerQueryValue(VerInfo, '\', pointer(VerValue), VerValueSize);
    with VerValue^ do
      begin
        V1 := dwFileVersionMS shr 16;
        V2 := dwFileVersionMS and $FFFF;
        V3 := dwFileVersionLS shr 16;
        V4 := dwFileVersionLS and $FFFF;
      end;
    FreeMem(VerInfo, VerInfoSize);
  end;
  </code></pre>