The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: georgek01 on March 14, 2011, 05:51:05 AM

Title: Version Info from Resource
Post by: georgek01 on March 14, 2011, 05:51:05 AM
Hello!

I would like to get the version number for my application as it starts up. This is what I have so far but I doubt I'm doing it correctly...


GetVersionInfo proc

invoke FindResource,NULL,1,RT_VERSION
.if eax != NULL
invoke LoadResource,NULL,eax
.if eax != NULL

mov eax,(VS_FIXEDFILEINFO ptr [eax]).dwProductVersionMS

invoke wsprintf,addr buffer,addr szNum,eax
invoke MessageBox,hWin,addr buffer,addr AppName,0

.endif
.endif

xor eax,eax
Ret
GetVersionInfo EndP



M$ says:
QuoteLoad Resource returns a handle to the global memory block containing the data associated with the resource.

My question is, how do I access the various memebers of the VS_FIXEDFILEINFO? Is the handle to the global memory block in fact pointing to this structure?

Any assistance/suggestions will be appreciated!

Title: Re: Version Info from Resource
Post by: donkey on March 14, 2011, 06:06:58 AM
As long as the version information is standard, you use the following

LOCAL Verification:DWORD
LOCAL RootPath:DWORD
LOCAL pVersion:DWORD
LOCAL pVersionLen:DWORD
LOCAL pProdName:DWORD
LOCAL szMyProgram[MAX_PATH]:BYTE

invoke GetModuleFileName,NULL,addr szMyProgram,MAX_PATH

invoke GetFileVersionInfoSize,addr szMyProgram,OFFSET Verification
or eax,eax
jz FAILED
push eax
invoke GlobalAlloc,GPTR,eax
mov ebx,eax
pop eax
invoke GetFileVersionInfo,addr szMyProgram,NULL,eax,ebx
mov [RootPath],"\"
invoke VerQueryValue,ebx,addr RootPath,addr pVersion,addr pVersionLen
invoke VerQueryValue,ebx,addr ProductQuery,addr pProdName,addr pVersionLen

; pVersion points to the packed version information

invoke GlobalFree,ebx
xor eax,eax
ret
FAILED:
;some error message
ret
Title: Re: Version Info from Resource
Post by: georgek01 on March 14, 2011, 06:13:34 AM
Thank you!