可以用共享内存来做。<br><br>unit MapFileUnit;<br><br>interface<br>uses<br> windows;<br>type<br> pCommonData = ^TCommonData;<br> TCommonData = record<br> //CallBackHandle: HWnd;<br> s: array[1..2] of string; //改成你要的内容 <br> end;<br><br>procedure MapCommonData(var CommonData
CommonData;var HMapFile:THandle);<br>procedure UnMapCommonData(var CommonData
CommonData;var HMapFile:THandle);<br><br>implementation<br><br>procedure MapCommonData(var CommonData
CommonData;var HMapFile:THandle);<br>var FirstCall: Boolean;<br>begin<br> HMapFile:=OpenFileMapping(FILE_MAP_WRITE, False, 'ZHUWEI_KEYBOARD');<br> FirstCall:=(HMapFile = 0);<br> if FirstCall then<br> HMapFile:=CreateFileMapping($FFFFFFFF,nil,PAGE_READWRITE,<br> 0,SizeOf(TCommonData),<br> 'ZHUWEI_KEYBOARD');<br> CommonData:= MapViewOfFile(HMapFile, FILE_MAP_WRITE, 0, 0, 0);<br> if FirstCall then FillChar(CommonData^, SizeOf(TCommonData), 0);<br>end;<br><br>procedure UnMapCommonData(var CommonData
CommonData;var HMapFile:THandle);<br>begin<br> try<br> UnMapViewOfFile(CommonData);<br> CommonData := nil;<br> CloseHandle(HMapFile);<br> HMapFile := 0;<br> except<br> MessageBox(0,<br> 'Error when free MapViewFile',<br> 'ZW Hook Error',<br> MB_OK);<br> end; //try<br>end;<br><br>end.<br><br>--------------------------<br>调用时:<br>var<br> HMapFile:THandle;<br> CommonData
CommonData;<br><br>procedure DLlMain(dwReason: DWORD); <br>begin <br> case dwReason of<br><br> DLL_PROCESS_ATTACH:<br> begin<br> HMapFile:=0;<br> MapCommonData(CommonData,HMapFile);<br> end; // DLL_PROCESS_ATTACH:<br><br> DLL_PROCESS_DETACH:<br> begin<br> if CommonData<>nil then UnMapCommonData(CommonData,HMapFile);<br> end; // DLL_PROCESS_DETACH:<br> <br> end; //calse<br>end;