Windows不自带秒表 写了个小东西 用来计时的 算是秒表了罢 可以精确到ms(Win32汇编)
;*****************************************************************************************************************;作者:zklhp
;Email:zklhp%(%<-@)
;QQ:493165744
;转载保留本信息可以么。。
;*****************************************************************************************************************
效果如图
程序+代码
timer.zip
(11.84 KB)
照顾不能下载的朋友帖下代码
程序代码:
;MASMPlus 代码模板 - 以对话框做为主窗口的程序 ;***************************************************************************************************************** ;作者:zklhp ;Email:zklhp%(%<-@) ;QQ:493165744 ;小程序 不求版权 但求转载保留本信息~~~ ;***************************************************************************************************************** .386 .Model Flat, StdCall Option Casemap :None Include windows.inc Include user32.inc Include kernel32.inc Include gdi32.inc includelib gdi32.lib IncludeLib user32.lib IncludeLib kernel32.lib include macro.asm include rsrc.inc DlgProc PROTO :DWORD,:DWORD,:DWORD,:DWORD .const DLG_MAIN equ 100 .data? hInstance dd ? hHook dd ? hWin dd ? dwLastCount dd ? .CODE ;用钩子不是很稳定 很可能崩溃~ HookProc proc uses ebx esi edi _dwCode,_wParam,_lParam local @szBuf[256]:BYTE local @point:POINT invoke CallNextHookEx,hHook,_dwCode,_wParam,_lParam pushad .if _dwCode == HC_ACTION mov ebx,_lParam assume ebx:ptr EVENTMSG ;[ebx].message == WM_SYSKEYDOWN 用于截取ALT的按键 至于按哪个键可以改的 .if [ebx].message == WM_KEYDOWN || [ebx].message == WM_SYSKEYDOWN mov eax,[ebx].paramL and eax,0ffh .if al == VK_CONTROL invoke GetTickCount mov esi,eax mov edi,eax invoke SetDlgItemInt,hWin,IDC_STC2,esi,FALSE invoke SetDlgItemInt,hWin,IDC_STC1,dwLastCount,FALSE sub esi,dwLastCount invoke SetDlgItemInt,hWin,IDC_STC3,esi,FALSE mov dwLastCount,edi ;每次写下当次的值作为Last Count .endif .endif assume ebx:nothing .endif popad xor eax,eax ret HookProc endp START: invoke GetModuleHandle,NULL mov hInstance,eax invoke DialogBoxParam,hInstance,IDD_DLG1,0,offset DlgProc,0 invoke ExitProcess,0 DlgProc proc hWnd,uMsg,wParam,lParam local @szBuf[256]:BYTE .if uMsg==WM_INITDIALOG push hWnd pop hWin invoke GetTickCount mov dwLastCount,eax invoke SetDlgItemInt,hWnd,IDC_STC1,eax,FALSE invoke SetWindowsHookEx,WH_JOURNALRECORD,addr HookProc,hInstance,NULL .if eax mov hHook,eax .else invoke MessageBox,0,CTXT('安装钩子出错 退出'),CTXT('出错'),0 invoke EndDialog,hWnd,NULL .endif .elseif uMsg==WM_COMMAND mov eax,wParam and eax,0ffffh .if eax==IDCANCEL invoke SendMessage,hWnd,WM_CLOSE,0,0 .endif .elseif uMsg==WM_CLOSE invoke UnhookWindowsHookEx,hHook invoke EndDialog,hWnd,wParam .else mov eax,FALSE ret .endif mov eax,TRUE ret DlgProc endp END START