N
newshenliang
Unregistered / Unconfirmed
GUEST, unregistred user!
据说可以像调用DLL一样调用Exe的输出函数,不知道怎么一直试都不行, 请大家帮帮忙!<br>十分感谢!<br>下面是我从论坛中搜索到的,说是可以调用,可在我这就是不行!我的编译器是Delphi7!<br>program TestExe; //输出函数的Exe<br>uses<br> Windows;<br>procedure Test(p: PChar); export; stdcall;<br>begin<br> MessageBox(0, p, 'Test', MB_OK);<br>end;<br>exports<br> Test;<br>begin<br>end.<br><br>procedure TForm1.Button1Click(Sender: TObject); //另一APP中调用<br>var<br> lib: THandle;<br> Test: procedure(p: PChar); stdcall;<br>begin<br> lib := LoadLibrary('TestExe.exe');<br> if lib = 0 then<br> ShowError('Cannot load the module')<br> else<br> begin<br> @Test := GetProcAddress(lib, 'Test');<br> if @Test = nil then<br> ShowError('Cannot GetProcAddress')<br> else Test('This is a test');//出现地址错误,为什么呢???<br> FreeLibrary(lib);<br> end;<br>end;<br><br>十分急,先谢谢大家!