发送端:#include <winapi.au3>
GUICreate('Send')
GUIRegisterMsg(0x4A, '_Rec')
_Send()
While 1
sleep(1000)
wend
Func _Send()
$hwnd = WinGetHandle('Rec')
$message = '发送端的信息,发送OK'
$struct = DllStructCreate('wchar var1[1000]')
DllStructSetData($struct, 1, $message)
$pStruct = DllStructGetPtr($struct)
$struct2 = DllStructCreate('dword;dword;ptr')
DllStructSetData($struct2, 1, 0)
DllStructSetData($struct2, 2, 1000)
DllStructSetData($struct2, 3, $pStruct)
$pStruct2 = DllStructGetPtr($struct2)
_SendMessage($hwnd, 0x4A, 0, $pStruct2)
Endfunc ;==>_Send
Func _Rec($hwnd, $iMsg, $iwParam, $ilParam)
$a1 = DllStructCreate('dword var1;dword var2;ptr var3', $ilParam)
$a2 = DllStructGetData($a1, 3)
$a3 = DllStructCreate('wchar var1[1000]', $a2)
$a4 = DllStructGetData($a3, 1)
MsgBox(0, '发送端收到', $a4)
EndFunc ;==>_Rec
接收端:#include <winapi.au3>
GUICreate('Rec')
GUIRegisterMsg(0x4A, '_Rec')
sleep(3000)
_send()
While 1
Sleep(1000)
WEnd
Func _send()
$hWnd = WinGetHandle('Send')
$message = '接收端的信息,发送ok'
$struct = DllStructCreate('wchar var1[1000]')
DllStructSetData($struct, 1, $message)
$pStruct = DllStructGetPtr($struct)
$struct2 = DllStructCreate('dword;dword;ptr')
DllStructSetData($struct2, 1, 0)
DllStructSetData($struct2, 2, 1000)
DllStructSetData($struct2, 3, $pStruct)
$pStruct2 = DllStructGetPtr($struct2)
_SendMessage($hWnd, 0x4A, 0, $pStruct2)
Endfunc ;==>_send
Func _Rec($hWnd, $iMsg, $iwParam, $ilParam)
$a1 = DllStructCreate('dword var1;dword var2;ptr var3', $ilParam)
$a2 = DllStructGetData($a1, 3)
$a3 = DllStructCreate('wchar var1[1000]', $a2)
$a4 = DllStructGetData($a3, 1)
MsgBox(0, '接收端收到', $a4)
EndFunc ;==>_Rec
上面的这个例子程序是我从论坛上搜到的,看了看例子只是两个程序间传递字符串数据,现在我需要的是send端给rec端发送的是一个数组,能修改利用这个例子吗?望高手出手,学习了 |