S
savenight
Unregistered / Unconfirmed
GUEST, unregistred user!
如题目。[]<br>觉得很简单,但...<br>1.做一个DLL,<br>
<br>2.新建一个工程1,然后调用DLL的GetGlobalMem向工程1里写入数据。<br>3再新建一个工程2,从这一个工程2中读出数据。[red]但结果却是为乱码[/red]。
代码:
library pDataDll;<br>uses<br> SysUtils,<br> Classes,<br> windows,<br> dialogs;<br>type<br> data=array[0..38] of integer;<br>var<br> hMem:thandle;<br> Pdata:^data;<br>function GetGlobalMem:Thandle;export;<br>begin<br> result:=hMem;<br>end;<br><br>{$R *.res}<br>exports<br> GetglobalMem;<br> <br>begin<br>hMem:=GlobalAlloc(gmem_MOVEABLE and gmem_DDEShare,sizeof(data));<br>if hMem=0 then<br>messagedlg('could not allocate memory',mtwarning,[mbok],0);<br>end.