ehxz 发表于 2015-1-15 21:29:02

pb 程序之间的消息传递

一、发送消息
long   ll_handle,ll_rtn
string ls_msg,ls_lenBlob   lblob_sndll_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_dataIf (wparam = 0) Or (lparam = 0) THEN RETURNSetNull(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(ulonghObject) 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"

telephone 发表于 2015-6-6 08:00:43

学习了、。。。

lifei1210 发表于 2022-1-15 21:25:27

收藏了,谢谢
页: [1]
查看完整版本: pb 程序之间的消息传递

免责声明:
本站所发布的一切破解补丁、注册机和注册信息及软件的解密分析文章仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。本站信息来自网络,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容。如果您喜欢该程序,请支持正版软件,购买注册,得到更好的正版服务。如有侵权请邮件与我们联系处理。

Mail To:Admin@SybaseBbs.com