[原创]用MASM32获取windows类型

王朝system·作者佚名  2006-01-09
宽屏版  字体: |||超大  

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

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
© 2005- 王朝网络 版权所有