Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
“Nice” application names
#2
Function GetFileVersionString extracts file description directly from exe. I tested it only with several programs, XP.

Code:
Copy      Help
;/
function# $file str&string [$infokind]

;Extracts string from version resource of exe or dll.
;infokind can be one of following strings (default is "FileDescription"):
;Comments InternalName ProductName CompanyName LegalCopyright ProductVersion FileDescription LegalTrademarks PrivateBuild FileVersion OriginalFilename SpecialBuild
;Returns 1 on success, 0 on failure.

;EXAMPLE
;str s
;if(GetFileVersionString("iexplore.exe" &s)) out s


dll# version GetFileVersionInfoSize $lptstrFilename *lpdwHandle
dll# version GetFileVersionInfo $lptstrFilename dwHandle dwLen !*lpData
dll# version VerQueryValue !*pBlock $lpSubBlock !**lplpBuffer *puLen

if(!infokind or !infokind[0]) infokind="FileDescription"

str file2.searchpath(file); if(!file2.len) end "file not found"
int i vis=GetFileVersionInfoSize(file2, &i); if(!vis) ret
str s.all(vis 2) ss; word* lc; lpstr ls
if(!GetFileVersionInfo(file2, i, vis, s)) ret
if(!VerQueryValue(s, "\VarFileInfo\Translation", &lc, &i) or !lc or !i) ret

ss.format("\StringFileInfo\%04x%04x\%s" lc[0] lc[1] infokind)
if(VerQueryValue(s, ss, &ls, &i)) goto return
;lc[0] has problems with some programs (Word, Excel)
ss.format("\StringFileInfo\0409%04x\%s" lc[1] infokind)
if(VerQueryValue(s, ss, &ls, &i)) goto return
ret
;return
string=ls
ret 1


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)