the following snippet is an approach to obtaining the langID and char-setID of a file which contains file version info.
alas, all i get is crap. the ID should be 040904B0, but i get something like 00409c8c which actually is NOT right.
any idea how to fix that?

; --- code snippet ---

verTranslate db "\VarFileInfo\Translation", 0
verInfo DWORD ?
verBuffer BYTE 100 dup(?)
buffer BYTE 256 dup(?)


; bufName = filename

invoke GetFileVersionInfoSize, addr bufName, addr lpdwHandle
.if (eax != 0)
mov verSize, eax
invoke GetFileVersionInfo, addr bufName, 0, verSize, addr buffer
.if (eax != 0)
invoke VerQueryValue, addr buffer, addr verTranslate, addr verInfo, addr verBuffer
.if (eax != 0)
; process code
.endif
.endif
.endif
Posted on 2002-11-27 09:45:20 by ploptor
ok, to make it even more specific:

how do i get the language and charset ID using VerQueryValue in combination with "\VarFileInfo\Translation"?
Posted on 2002-11-28 09:39:58 by ploptor
Posted on 2002-11-28 12:03:52 by prs
i've also tried pascal and vb source, but it won't work anyway. so if you could help ... please post an example, or write a pm, or write me an email. PLEASE!
Posted on 2002-11-28 12:49:15 by ploptor
sure give me till the end of the day
and i'll whip something up.
take care
prs
Posted on 2002-11-28 12:54:51 by prs
this works for me.
using it on LINK.EXE
i Get 040904b0


.686p

.model flat, stdcall


include windows.inc
include kernel32.inc
include user32.inc
include version.inc
include comdlg32.inc

includelib kernel32.lib
includelib user32.lib
includelib version.lib
includelib comdlg32.lib

;from masm32
m2m MACRO M1, M2
push M2
pop M1
ENDM

LANGANDCODEPAGE STRUCT
wLanguage dw ?
wCodepage dw ?
LANGANDCODEPAGE ends

GetFileName PROTO :DWORD, :DWORD, :DWORD
.const

.data
szTitle db "Open A Exe File",0
szFilter db "All Exe's",0,"*.Exe",0,0
szSubBlock db "\VarFileInfo\Translation",0
szFormatStr db "language\Codepage =%04x%04x",0


.data?
lpSize dd ?
szFileName db MAX_PATH dup(?)
szFormatRes db 128 dup (?)
ofn OPENFILENAME <>

dwLength dd ?
lplpReturnVal dd ?
lpBuff db 2000 dup(?)

.code

start:
;pick a file
invoke GetFileName, NULL, addr szTitle, addr szFilter
cmp szFileName[0], 0
jz @@Exit


;fill our buffer
invoke GetFileVersionInfo, addr szFileName, NULL, 2000, addr lpBuff


;now get our info
;this retunrs our pointer
invoke VerQueryValue, addr lpBuff, addr szSubBlock, addr lplpReturnVal, addr dwLength


;do we have data for this exe and this block?
mov ecx, dword ptr
.if( eax != 0 && ecx > 0 )

;get our pointer to a pointer
mov eax, dword ptr


;make sure were zeros
xor ecx, ecx
xor edx, edx

;store it
assume eax:PTR LANGANDCODEPAGE

movzx ecx, .wLanguage
movzx edx, .wCodepage

assume eax:NOTHING

;format it
invoke wsprintf, addr szFormatRes, addr szFormatStr, ecx,edx

;display it
invoke MessageBox, NULL, addr szFormatRes, addr szFormatRes, MB_OK

.endif

invoke GetLastError
@@Exit:
invoke ExitProcess, NULL

; From Masm32 thanks hutch
; #########################################################################

GetFileName proc hParent:DWORD,lpTitle:DWORD,lpFilter:DWORD

mov ofn.lStructSize, sizeof OPENFILENAME
m2m ofn.hWndOwner, hParent
m2m ofn.hInstance, NULL
m2m ofn.lpstrFilter, lpFilter
m2m ofn.lpstrFile, offset szFileName
mov ofn.nMaxFile, sizeof szFileName
m2m ofn.lpstrTitle, lpTitle
mov ofn.Flags, OFN_EXPLORER or OFN_FILEMUSTEXIST or \
OFN_LONGNAMES

invoke GetOpenFileName,ADDR ofn

ret

GetFileName endp

end start

Posted on 2002-11-28 20:06:25 by prs
big thanx! it works just fine. i dont think the .686p was necessary, but it doesnt matter.

:) :) :)
Posted on 2002-11-29 01:29:08 by ploptor
.386 would be fine, since you don't use cmovxx and other added features.
Posted on 2002-11-29 07:44:37 by roticv
the 686p stuff is just a template i use.
boiler plate stuff.
glad it worked for you
take care
prs
Posted on 2002-11-29 13:10:41 by prs