EXE输出函数
Exe 可以调用Exe的输出,不知道以前怎么一直试都不行, 现在一部到位:
program TestExe; //输出函数的Exe
uses
Windows;
procedure Test(p: PChar); export; stdcall;
begin
MessageBox(0, p, 'Test', MB_OK);
end;
exports
Test;
begin
end.
procedure TForm1.Button1Click(Sender: TObject); //另一APP中调用
var
lib: THandle;
Test: procedure(p: PChar); stdcall;
begin
lib := LoadLibrary('TestExe.exe');
if lib = 0 then
ShowError('Cannot load the module')
else
begin
@Test := GetProcAddress(lib, 'Test');
if @Test = nil then
ShowError('Cannot GetProcAddress')
else Test('This is a test');
FreeLibrary(lib);
end;
end;