Au3如何读取一个已建立的内存映射?[已解决]
本帖最后由 oceanwind 于 2012-7-23 18:31 编辑以下的C++控制台可以读出来名为 jzt_output_price的映射对象 但AU3不知道咋个写 求指教 谢谢先
#include "stdafx.h"
#include <Windows.h>
#include <iostream>
#include <string>
using namespace std;
DWORD WINAPI FirstThread(PVOID pvParam);
int _tmain(int argc, _TCHAR* argv[])
{
HANDLE hFilemap1 = OpenFileMapping(FILE_MAP_READ|FILE_MAP_WRITE,FALSE,_T("jzt_output_price")); //打开名为 jzt_output_price的映射对象.
if(hFilemap1 == NULL)
{
cout<<"openfilemapping 失败"<<endl;
}
float *pView = (float*)MapViewOfFile(hFilemap1,FILE_MAP_READ|FILE_MAP_WRITE,0,0,0);
if(pView == NULL)
{
cout<<"map view 失败"<<endl;
}
else
{
cout<<*pView;
UnmapViewOfFile(pView);
}
CloseHandle(hFilemap1);
system("pause");
return 0;
} 写了一下 写不下去了
$hFilemap1 = dllcall("Kernel32.dll","HANDLE","OpenFileMappingW","dword","FILE_MAP_READ|FILE_MAP_WRITE","BOOL","FALSE","wstr","jzt_output_price")
$a_hCall =dllcall("Kernel32.dll","ptr","MapViewOfFile","hwnd",$hFilemap1,"dword","FILE_MAP_READ|FILE_MAP_WRITE","DWORD",0,"DWORD",0,"DWORD",0) 看到一个贴子发现一种新的AU3进程通信,非wm_copydatahttp://bbs.wglm.net/forum.php?mod=viewthread&tid=141123&highlight=
直接用
_WinAPI_OpenFileMapping
但是在线文档和帮助中没有发现这个函数啊
Const $FILE_MAP_READ = 4
Const $FILE_MAP_WRITE = 2
Const $SECTION_NAME = "jzt_output_price"
Local $hSection = OpenFileMapping(BitOR($FILE_MAP_READ, $FILE_MAP_WRITE), 0, $SECTION_NAME)
Local $pBaseAddress = MapViewOfFile($hSection, BitOR($FILE_MAP_READ, $FILE_MAP_WRITE), 0, 0, 0)
; Do something with the $pBaseAddress
UnmapViewOfFile($pBaseAddress)
CloseHandle($hSection)
Func OpenFileMapping($iDesiredAccess, $fInheritHandle, $sSectionName)
Local $iResult
$iResult = DllCall("Kernel32.dll", "handle", "OpenFileMappingW", "dword", $iDesiredAccess, "bool", $fInheritHandle, "wstr", $sSectionName)
Return $iResult
EndFunc ;==>OpenFileMapping
Func MapViewOfFile($hSection, $iDesiredAccess, $iOffsetHigh, $iOffsetLow, $iNumberofBytesToMap)
Local $iResult
$iResult = DllCall("Kernel32.dll", "ptr", "MapViewOfFile", "handle", $hSection, "dword", $iDesiredAccess, "long", $iOffsetHigh, "long", $iOffsetLow, "long", $iNumberofBytesToMap)
Return $iResult
EndFunc ;==>MapViewOfFile
Func CloseHandle($hObject)
Local $iResult
$iResult = DllCall("Kernel32.dll", "bool", "CloseHandle", "handle", $hObject)
Return $iResult
EndFunc ;==>CloseHandle
Func UnmapViewOfFile($pBaseAddress)
Local $iResult
$iResult = DllCall("Kernel32.dll", "bool", "UnmapViewOfFile", "ptr", $pBaseAddress)
Return $iResult
EndFunc ;==>UnmapViewOfFile
进程通信必须要满足两个原则,一是能够数据共享,二是必须有线程同步机制。用内存映射的方式来回传递数据并不算真正意义上的进程通信,因为它只有数据共享,而没有线程同步,所以就必须在一个循环中实时监测内存中的数据。 进程通信必须要满足两个原则,一是能够数据共享,二是必须有线程同步机制。用内存映射的方式来回传递数 ...
pusofalse 发表于 2012-7-23 16:58 http://www.autoitx.com/images/common/back.gif
太感谢.......... 留个名,向高手学习 学习了,今天又小积一点。 大神 分享,学习一下
页:
[1]