send的代码:
.386
.Model Flat,StdCall
Option CaseMap:None
;###########################################
;
include Windows.inc
include user32.inc
includelib user32.lib
include kernel32.inc
includelib kernel32.lib
;###########################################
.data
hWnd dd ?
szBuffer dd 256 dup (?)
;******************************************
.const
szCaption db 'SendMessage',0
szStart db 'Press OK to start SendMessage,param :%8x!',0
szReturn db 'SendMessage returned!',0
szDestClass db 'MyClass',0
szText db 'Text send to other windows',0
szNotFound db 'Receive Message Window not found!',0
;**********************************************************
.code
start:
invoke FindWindow,addr szDestClass,NULL
.if eax
mov hWnd,eax
invoke wsprintf,addr szBuffer,addr szStart,addr szText
invoke MessageBox,NULL,offset szBuffer,/
offset szCaption,MB_OK
invoke SendMessage,hWnd,WM_SETTEXT,0,addr szText
invoke MessageBox,NULL,offset szReturn,/
offset szCaption,MB_OK
.else
invoke MessageBox,NULL,offset szNotFound,/
offset szCaption,MB_OK
.endif
invoke ExitProcess,NULL
; **********************************
end start
receie的代码:
.386
.Model Flat,StdCall
Option CaseMap:None
;###########################################
;
include Windows.inc
include user32.inc
includelib user32.lib
include kernel32.inc
includelib kernel32.lib
;###########################################
.data
hWnd dd ?
szBuffer dd 256 dup (?)
;******************************************
.const
szCaption db 'SendMessage',0
szStart db 'Press OK to start SendMessage,param :%8x!',0
szReturn db 'SendMessage returned!',0
szDestClass db 'MyClass',0
szText db 'Text send to other windows',0
szNotFound db 'Receive Message Window not found!',0
;**********************************************************
.code
start:
invoke FindWindow,addr szDestClass,NULL
.if eax
mov hWnd,eax
invoke wsprintf,addr szBuffer,addr szStart,addr szText
invoke MessageBox,NULL,offset szBuffer,/
offset szCaption,MB_OK
invoke SendMessage,hWnd,WM_SETTEXT,0,addr szText
invoke MessageBox,NULL,offset szReturn,/
offset szCaption,MB_OK
.else
invoke MessageBox,NULL,offset szNotFound,/
offset szCaption,MB_OK
.endif
invoke ExitProcess,NULL
; **********************************
end start
本文介绍了一种使用汇编语言(ASM)实现不同窗口间消息发送与接收的方法。通过具体的代码示例展示了如何利用Windows API函数FindWindow、MessageBox及SendMessage来定位目标窗口并发送文本消息。
4576

被折叠的 条评论
为什么被折叠?



