A message only window is a special window not visible ( no GUI interface ) and designed to send and receive messages. The code below creates a timer and deletes a file named test12345.txt before destroying itself after 3 seconds.
.386
.model flat,stdcall
option casemap:none
include MsgOnlyWnd.inc
.data
ClassName db 'MessageOnlyWindow',0
file db 'test12345.txt',0
.data?
hInstance dd ?
wc WNDCLASSEX <?>
msg MSG <?>
.code
start:
invoke GetModuleHandle,0
mov hInstance,eax
mov wc.cbSize,SIZEOF WNDCLASSEX
mov wc.lpfnWndProc,OFFSET WndProc
mov wc.hInstance,eax
mov wc.lpszClassName,OFFSET ClassName
invoke RegisterClassEx,ADDR wc
xor eax,eax
invoke CreateWindowEx,NULL,ADDR ClassName,eax,\
eax,eax,eax,eax,eax,\
HWND_MESSAGE,eax,hInstance,eax
.WHILE TRUE
invoke GetMessage,ADDR msg,NULL,0,0
.BREAK .IF (!eax)
invoke TranslateMessage,ADDR msg
invoke DispatchMessage,ADDR msg
.ENDW
invoke ExitProcess,0
WndProc PROC hWnd:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD
.IF uMsg==WM_CREATE
invoke SetTimer,hWnd,ID_TIMER,3000,ADDR TimerProc
.ELSEIF uMsg==WM_DESTROY
invoke PostQuitMessage,NULL
.ELSE
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret
.ENDIF
xor eax,eax
ret
WndProc ENDP
TimerProc PROC hWnd:DWORD,uMsg:DWORD,idEvent:DWORD,dwTime:DWORD
invoke exist,ADDR file
test eax,eax
jz @f
invoke DeleteFile,ADDR file
@@:
invoke KillTimer,hWnd,ID_TIMER
xor eax,eax
invoke SendMessage,hWnd,WM_DESTROY,eax,eax
ret
TimerProc ENDP
exist PROC lpszFileName:DWORD ; function from masm32.lib
LOCAL wfd:WIN32_FIND_DATA
invoke FindFirstFile,lpszFileName,ADDR wfd
.if eax == INVALID_HANDLE_VALUE
xor eax,eax ; 0 = NOT exist
.else
invoke FindClose,eax
mov eax,1 ; 1 = exist
.endif
ret
exist ENDP
END start