body{font:9pt/14pt 宋体, MSSong;};#1{color:#0000D0};#2{color:#FF0000};#3{color:#008000};#4{color:#808080};#5{color:#FF00FF};#6{color:#FF0000}
body{font:9pt/14pt 宋体, MS Song;}
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
;Function: Display the Windows type
; Author:purple endurer
; Develop: MASM32 V8
;Log
;------------------------------------
; 2005-04-29 Create
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
.386
.model flat, stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
GetWinType PROTO
.data
g_szWin95 db "Windows 95", 0
g_szWin98 db "Windows 98", 0
g_szWinMe db "Windows Mellinnium", 0
g_szWinNT351 db "Windows NT 3.51", 0
g_szWinNT40 db "Windows NT 4.0", 0
g_szWin2000 db "Windows 2000", 0
g_szWinXP db "Windows XP", 0
g_szWin2003 db "Windows Server 2003", 0
g_szUnknow db "Unknow", 0
.data?
g_OsVerInfo OSVERSIONINFO <>
.code
start:
mov g_OsVerInfo.dwOSVersionInfoSize, SIZEOF OSVERSIONINFO
invoke GetVersionEx, ADDR g_OsVerInfo
.if eax != 0
invoke GetWinType
invoke MessageBox, NULL, eax, eax, MB_OK
.endif
invoke ExitProcess, NULL
;//////////////////////////////////////////
;Function: Get the Windows type
; Input: g_OsVerInfo
; Output: Pointer to the string of windows type
;//////////////////////////////////////////
GetWinType proc
push ebx ;用ebx作为临时变量
mov eax, OFFSET g_szUnknow;假设返回值为Unknow
mov ebx, g_OsVerInfo.dwPlatformId
.if ebx==1
mov ebx, g_OsVerInfo.dwMinorVersion
.IF ebx==0
mov eax, OFFSET g_szWin95
.ELSEIF ebx==10
mov eax, OFFSET g_szWin98
.ELSEIF ebx==90
mov eax, OFFSET g_szWinMe
.ENDIF
.elseif ebx==2
mov ebx, g_OsVerInfo.dwMajorVersion
.IF ebx==3
mov eax, OFFSET g_szWinNT351
.ELSEIF ebx==4
mov eax, OFFSET g_szWinNT40
.ELSEIF ebx==5
mov ebx, g_OsVerInfo.dwMinorVersion
.if ebx==0
mov eax, OFFSET g_szWin2000
.elseif ebx==1
mov eax, OFFSET g_szWinXP
.elseif ebx==2
mov eax, OFFSET g_szWin2003
.endif
.ENDIF
.endif
pop ebx
ret
GetWinType endp
end start
本文地址:http://com.8s8s.com/it/it22057.htm