[原創]用MASM32編程擷取windows類型

來源:互聯網
上載者:User
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
;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

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.