I'm trying to use this function to retrieve version details of an executable. I noted that there was a less specific discussion about this in 2001.

I'm using the following code,
Declare DllFunc "long GetFileVersionInfoSizeA(str, ulong*) version" GetFileVersionInfoSize
Declare DllFunc "long GetFileVersionInfoA(str, long, long, str) version" GetFileVersionInfo
Declare DllFunc "long VerQueryValueA(str, str, str*, ulong*) version" VerQueryValue

Function Main
var len=0
var sFileName, BufferLen = 0, sBuffer = 0
var bRep = 0, bQuery = 0
var sBuff, lSize = 0

sFileName = "I:\Program Files\Windows NT\Accessories\wordpad.exe"

if FileExists(sFileName) then
BufferLen = GetFileVersionInfoSize(sFileName, null)
print "Len: " + BufferLen
SetStrLen(sBuffer, BufferLen)
bRep = GetFileVersionInfo(sFileName, 0, BufferLen, sBuffer)
print "sBuffer: " + sBuffer

if bRep then
bQuery = VerQueryValue(sBuffer, "\StringFileInfo\040904B0\" +
"LegalTrademarks", sBuff, lSize)
if bQuery then
print lSize, "'" + sBuff + "'"
msgbox("File not found", sFileName)
End Function ; Main
resulting in,

Len: 1700
sBuffer: P4

The sBuffer is not what I would have expected, when used previously this has returned a large string.

Any top tips, blatant errors?