D
deardragon_2002
Unregistered / Unconfirmed
GUEST, unregistred user!
dll源码:<br>unit Unit1;<br><br>interface<br><br>uses<br> sysutils, windows, dialogs;<br><br>function MessageLook(sss: string): string; stdcall;<br><br>implementation<br><br>function MessageLook(sss: string): string; stdcall;<br>var<br> s: PCHar;<br>begin<br> Result := 'zhangqiujunDll!';<br> //Strcopy(PChar(p), s);<br> //Result := True; //<br> //showmessage(Result);<br> //Result := 5;<br>end;<br><br>end.<br><br><br><br>以下是调用过程:<br><br>implementation<br><br>uses<br> unit2;<br><br>{$R *.dfm}<br>var<br> DLLHandle: THandle;<br>//var<br>type<br> TMessageLook = function(s: string): string;<br>var<br> MessageLook: TMessageLook;<br>procedure LoadDLL;<br>var<br> str: string;<br>begin<br> try<br> DLLHandle := LoadLibrary('Project2.dll');<br> if DLLHandle >= 32 then<br> begin<br> @MessageLook := GetProcAddress(DLLHandle,'MessageLook');<br> Assert(@MessageLook <> nil);<br> str := Form1.edit1.text;<br> str := MessageLook(str);<br> //str := p[1];<br> showmessage(str);<br> end;<br> finally<br> //FreeLibrary(DLLHandle);<br> end;<br>end;<br><br><br>请高手指点为什么不能访问MessageLook函数?