注册 登录
编程论坛 汇编论坛

定时过程的学习练习-关闭****窗口程序

win_pig 发布于 2008-11-14 14:46, 1592 次点击
.386
.model flat,stdcall
option casemap:none
;━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
; Include 定义
;────────────────────────────────
include      windows.inc
include       user32.inc
includelib     user32.lib
include       kernel32.inc
includelib     kernel32.lib

;--------------------------------------------------------------------
; 数据段
;--------------------------------------------------------------------
        .data?
;──────────────────────────────────
    
hqqNews        dd    ?    
_count        dd    ?    ;计数

;--------------------------------------------------------------------
;常数定义
;--------------------------------------------------------------------
        .const
;──────────────────────────────────
_dqqNewsWindow    db    '通用对话框示例',0  ;窗口标题

;--------------------------------------------------------------------
; 代码段
;--------------------------------------------------------------------
    .code
;--------------------------------------------------------------------
;定时器过程
;━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
_Proctime    proc    

        inc _count
        invoke FindWindow, NULL,addr _dqqNewsWindow
        .if eax
            invoke SendMessage, eax,WM_CLOSE,NULL,NULL   
        .endif
        ret
_Proctime    endp

;--------------------------------------------------------------------
;主过程--建立定时器与消息循环
;━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
_proc_min    proc    
        local @stMsg : MSG
        
        mov _count,1
        invoke    SetTimer,NULL,NULL,1000,addr _Proctime
        mov hqqNews,eax
        .while    TRUE
            .break    .if _count > 500      ;每次1秒,500约为8分钟后退出程序。
            invoke    GetMessage,addr @stMsg,NULL,0,0
            invoke    TranslateMessage,addr @stMsg
            invoke    DispatchMessage,addr @stMsg
        .endw
        invoke    KillTimer ,NULL,hqqNews
        ret
_proc_min    endp
;━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
start:
        call _proc_min
        invoke    ExitProcess,NULL
;━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
    end    start

[[it] 本帖最后由 win_pig 于 2008-11-14 14:53 编辑 [/it]]
3 回复
#2
cnhanxiao2008-11-14 14:58
鼓励原创!很好的帖子!
#3
zklhp2008-11-14 15:41
不错 支持一下
#4
ONEPROBLEM2008-11-14 22:21
强!向楼主学习~~
1