EXE输出函数

I

import

Unregistered / Unconfirmed
GUEST, unregistred user!
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;
 

Similar threads

S
回复
0
查看
431
swish
S
S
回复
0
查看
602
SUNSTONE的Delphi笔记
S
S
回复
0
查看
514
SUNSTONE的Delphi笔记
S
S
回复
0
查看
931
SUNSTONE的Delphi笔记
S
S
回复
0
查看
755
SUNSTONE的Delphi笔记
S
顶部