;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Filename: getIEver2.asm
; Function: get & display version of IE
; Author: purple endurer
; Develop: win 2K pro + masm32
; log
;------------------------------------------------------------------
;2005.10.23 Created!
; get the version of IE from value of key "Vesion" at
; \HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer
; In my PC, the version of IE is 6.0.2800.1106
; and this program displayed version is 6.0.2800.1106
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
;下载:您可以到http://purpleendurer.ys168.com的/myworks/demo_only中
;下载源代码和可执行文件
.386
.model flat, stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\Advapi32.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
includelib \masm32\lib\Advapi32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib
GetIEVerStr PROTO :LPSTR
m_m2m MACRO d1, d2
push d2
pop d1
ENDM
.data
g_szTitle db "IE版本", 0
g_szRegPath db "Software\Microsoft\Internet Explorer", 0
g_szFailRegOpenKeyEx db "RegOpenKeyEx失败!", 0
g_szFailRegQueryValueEx db "RegQueryValueEx失败!", 0
g_szValueName db "Version", 0
.data?
g_szIEVer db 256 dup(?)
g_hRegKey4IE HKEY ?
.code
start:
invoke GetIEVerStr, ADDR g_szIEVer
.if eax==1
mov eax, OFFSET g_szFailRegOpenKeyEx
.elseif eax==2
mov eax, OFFSET g_szFailRegQueryValueEx
.else
mov eax, OFFSET g_szIEVer
.endif
invoke MessageBox, NULL, eax, OFFSET g_szTitle, MB_OK
invoke ExitProcess,NULL
GetIEVerStr PROC lpszIEVer: LPSTR
LOCAL dwcbData: dword
; LONG RegOpenKey(
; HKEY hKey, // handle of open key
; LPCTSTR lpSubKey, // address of name of subkey to open
; PHKEY phkResult // address of handle of open key
; );
invoke RegOpenKey, HKEY_LOCAL_MACHINE, ADDR g_szRegPath, ADDR g_hRegKey4IE
.if eax!=ERROR_SUCCESS
m_m2m eax, 1
ret
.endif
; LONG RegQueryValueEx(
; HKEY hKey, // 1.handle of key to query
; LPTSTR lpValueName, // 2.address of name of value to query
; LPDWORD lpReserved, // 3.reserved
; LPDWORD lpType, // 4.address of buffer for value type
; LPBYTE lpData, // 5.address of data buffer
; LPDWORD lpcbData // 6.address of data buffer size
; );
m_m2m dwcbData, SIZEOF g_szIEVer
invoke RegQueryValueEx, g_hRegKey4IE, ADDR g_szValueName, NULL, NULL, ADDR g_szIEVer, ADDR dwcbData
.if eax!=ERROR_SUCCESS
m_m2m eax, 2
.else
xor eax, eax
.endif
; LONG RegCloseKey(
; HKEY hKey // handle of key to close
; );
invoke RegCloseKey, g_hRegKey4IE
ret
GetIEVerStr ENDP
end start