马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?站点注册
×
一、发送消息
long ll_handle,ll_rtn
string ls_msg,ls_len Blob lblob_snd ll_handle = long(profilestring(guo_sys.is_inifile,'Set','handle','0'))//主程序窗口,可以通过FindWindowA取得
if ll_handle <> 0 then
ls_msg = '消息'
//计算整个要发送字符的长度,并转化为长度为10的字符串
ls_len = String(Len(ls_msg))
IF Len(ls_len) < 10 THEN
ls_len = Space(10 - Len(ls_len))+ls_len
END IF lblob_snd = Blob(ls_len + ls_msg)
SndMsg(ll_handle,1024,getcurrentprocessID(),lblob_snd)//发送pbm_custom01消息给主程序
end if 二、主程序接收消息(窗口的pbm_custom01事件) //wparam 发送的进程ID //lparam 发送的进程里的消息地址 Long ll_null,ll_processhnd,ll_size
String ls_size,ls_data
blob lb_data If (wparam = 0) Or (lparam = 0) THEN RETURN SetNull(ll_null)
ll_processhnd = openprocess(PROCESS_VM_READ,0,wparam);
//读取发送进程的内存数据 ls_size = Space(10) //数据的大小
ReadProcessMemoryStr(ll_processhnd,lparam,ls_size,10,ll_null)
ll_size = Long(Trim(ls_size)) lb_data = Blob(String(Space(ll_size))) //读取消息内容
ReadProcessMemoryBlob(ll_processhnd,lparam+10,lb_data,ll_size,ll_null) ls_data = String(lb_data)//接收到的消息
CloseHandle(ll_processhnd) 三、相关API //接收相关 Function ulong OpenProcess(ulong dwDesiredAccess,ulong bInheritHandle,ulong dwProcessId) LIBRARY "kernel32.dll"
Function ulong CloseHandle(ulong hObject) LIBRARY "kernel32.dll"
Function ulong ReadProcessMemoryStr(ulong hProcess,long lpBaseAddress,ref string lpBuffer,ulong nSize,ref long lpNumberOfBytesWritten) LIBRARY "kernel32.dll" Alias for "ReadProcessMemory"
Function ulong ReadProcessMemoryBlob(ulong hProcess,long lpBaseAddress,ref blob lpBuffer,ulong nSize,ref long lpNumberOfBytesWritten) LIBRARY "kernel32.dll" Alias for "ReadProcessMemory"
//发送相关 Function ulong GetCurrentProcessId() LIBRARY "kernel32.dll"
Function integer SndMsg(long hWnd, long uMsg, long url, ref blob info) library "user32.dll" Alias For "SendMessageA"
|