⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 meter.asm

📁 在vc下开发的系统资源显示器
💻 ASM
字号:
;the following are not needed for this program to work.  Ther are used to make the hyper link
;shell32.inc  Shell32.lib  gdi32.inc  gdi32.lib
;szOpen and szLink
;spoo and hFinger
;Hyperlink and HyperLinkWndProc  proto's and Procs
;LoadCursor in WM_INITDIALOG
;invoke HyperLink,hWin,3001 in WM_INITDIALOG
;And lastly none of the WM_CTLCOLORSTATIC is needed
      .386
      .model flat, stdcall
      option casemap :none   ; case sensitive

      include \masm32\include\windows.inc
      include \masm32\include\user32.inc
      include \masm32\include\kernel32.inc
      include \masm32\include\comctl32.inc
      include \masm32\include\shell32.inc
      include \masm32\include\gdi32.inc
      includelib \masm32\lib\shell32.lib
      includelib \masm32\lib\gdi32.lib
      includelib \masm32\lib\user32.lib
      includelib \masm32\lib\kernel32.lib
      includelib \masm32\lib\comctl32.lib
          
        WndProc PROTO :DWORD,:DWORD,:DWORD,:DWORD
        HyperLink PROTO :DWORD, :DWORD
        HyperLinkWndProc PROTO :DWORD, :DWORD, :DWORD, :DWORD

    .data
        dlgname     db "METER",0
        szLibName   db "rsrc32.dll",0  ;dll the function we need is in
        szProcName  db "_MyGetFreeSystemResources32@4",0 ;name of the function

        szSystem    db "System Resources %i%% free",0   ;wsprintf strings %i telss it to add a
        szUser      db "User Resources %i%% free",0     ;integer. %% tells it we want the % sign
        szGdi       db "Gdi resources: %i%% free",0

        szOpen      db "open",0
        szLink      db "http://betrayed.virtualave.net/",0
        
    .data   ;variables to hold our handles
        hInstance   dd ?
        hLib        dd ?
        hProc       dd ?
        hGdi        dd ?
        hSystem     dd ?
        hUser       dd ?
        buffer      db 64 dup (?) ;buffer to hold the returns from wsprintf

        spoo        dd ?
        hFinger     dd ?

    .code

start:

      invoke InitCommonControls     ;So we can use the progress bars
      invoke GetModuleHandle, NULL
      mov hInstance, eax
      invoke LoadLibrary,addr szLibName     ;Load rsrc32.dll and save it hDll so we can unload it when through
         mov hLib,eax
      invoke GetProcAddress,hLib,addr szProcName ;Get our main function handle and save it
         mov hProc,eax
      invoke DialogBoxParam,hInstance,ADDR dlgname,0,ADDR WndProc,0  ;load the main window
      invoke ExitProcess,eax

WndProc proc hWin   :DWORD,
             uMsg   :DWORD,
             wParam :DWORD,
             lParam :DWORD

      .if uMsg == WM_INITDIALOG 
         invoke LoadIcon,hInstance,101  ;load icon from the resources
         invoke SendMessage,hWin,WM_SETICON,0,eax   ;set it on the title bar
         invoke HyperLink,hWin,3001
         invoke SetTimer,hWin,5000,100,0    ;Set the timer
         invoke LoadCursor,hInstance,201
            mov hFinger,eax

            xor eax,eax 
                ret
      .elseif uMsg == WM_CTLCOLORSTATIC
        invoke SendMessage,lParam,uMsg,wParam,lParam
            ret
      .elseif uMsg == WM_COMMAND
        .if wParam == 3000  ;exit button
            invoke SendMessage,hWin,WM_CLOSE,NULL,NULL  ;Send a close message so it kills the timer
                xor eax,eax
                    ret
        .endif
      .elseif uMsg == WM_TIMER
            push 0                  ;0 = System memory. We need to push and call the functio
            call hProc              ;because we don't have a proto to use invoke with.
                mov hSystem,eax
            push 1                  ;1 = GDI
            call hProc
                mov hGdi,eax
            push 2                  ;2 = User
            call hProc
                mov hUser,eax
                
            invoke wsprintf,addr buffer,addr szSystem,hSystem   ;wsprintf to put the integer into a string
            invoke SetDlgItemText,hWin,2000,addr buffer         ;Update the static Text
            invoke SendDlgItemMessage,hWin,1000,PBM_SETPOS,hSystem,0    ;update the progress bar

;The next two are the same as above

            invoke wsprintf,addr buffer,addr szSystem,hUser
            invoke SetDlgItemText,hWin,2001,addr buffer
            invoke SendDlgItemMessage,hWin,1001,PBM_SETPOS,hUser,0

            invoke wsprintf,addr buffer,addr szGdi,hGdi
            invoke SetDlgItemText,hWin,2002,addr buffer
            invoke SendDlgItemMessage,hWin,1002,PBM_SETPOS,hGdi,0
                    xor eax,eax
                        ret
      .elseif uMsg == WM_CLOSE
        invoke KillTimer,hWin,5000  ;kill our timer since we won't need it now
        invoke FreeLibrary,hLib     ;unload the dll
        invoke EndDialog,hWin,0     ;end the program
            xor eax,eax
            ret
      .endif

    xor eax, eax 
    ret

WndProc endp

HyperLink proc hDlg:DWORD, nID:DWORD
    invoke GetDlgItem, hDlg, nID
        push eax
    invoke SetWindowLong, eax, GWL_WNDPROC, addr HyperLinkWndProc
        pop edx
    invoke SetWindowLong, edx, GWL_USERDATA, eax
        ret
    xor eax,eax
        ret
HyperLink endp

HyperLinkWndProc PROC hWnd:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD
LOCAL tmpFont  :LOGFONT 

.IF uMsg==WM_CTLCOLORSTATIC
    invoke SendMessage, hWnd, WM_GETFONT, 0, 0 
        mov spoo,eax
    invoke GetObject, spoo, sizeof LOGFONT, addr tmpFont ;
        mov tmpFont.lfUnderline, TRUE ;under line the link
    invoke CreateFontIndirect, addr tmpFont
    invoke SelectObject, wParam, eax
    invoke SetTextColor, wParam, Red ;change this to change the color of the link
    invoke GetSysColor, COLOR_MENU
    invoke SetBkColor, wParam, eax
    invoke GetStockObject, HOLLOW_BRUSH
        ret 
.ELSEIF uMsg==WM_NCHITTEST
    mov eax, 1 
        ret
.ELSEIF uMsg==WM_LBUTTONDOWN
    invoke ShellExecute, NULL, offset szOpen, offset szLink, NULL, NULL, SW_SHOWNORMAL ;change this to represent your preset url
    xor eax,eax
        ret
.ELSEIF uMsg==WM_SETCURSOR
    invoke SetCursor,hFinger
    xor eax,eax
        ret
.ENDIF
    invoke GetWindowLong, hWnd, GWL_USERDATA 
    invoke CallWindowProc, eax, hWnd, uMsg, wParam, lParam 
        ret
    xor eax, eax
    ret
HyperLinkWndProc endp

end start

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -