1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
procedure TestExport(const AMsg: string; AMemo: TMemo);
var
sNom: string;
begin
sNom := ExtractFilePath(Application.ExeName) + 'Project3.exe';
AMemo.Lines.Add(AMsg);
AMemo.Lines.Add(' HND nil : ' + IntToStr(GetModuleHandle(nil)));
AMemo.Lines.Add(' HND "'+ExtractFileName(snom)+'" : ' + IntToStr(GetModuleHandle(PChar(snom))));
AMemo.Lines.Add(' IsLibrary : ' + BoolToStr(IsLibrary, true));
AMemo.Lines.Add(' ModuleIsLib : ' + BoolToStr(ModuleIsLib, true));
AMemo.Lines.Add(' GetModuleName : ' + GetModuleName(0));
AMemo.Lines.Add(' MainInstance : ' + IntToStr(MainInstance));
AMemo.Lines.Add(' HInstance : ' + IntToStr(HInstance));
AMemo.Lines.Add(' paramStr : ' + ParamStr(0));
AMemo.Lines.Add('');
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
TestExport('Ajouté par self', Memo1);
end;
procedure TForm1.Button2Click(Sender: TObject);
var
hnd: THandle;
p: TTestExport;
begin
hnd := LoadLibrary(PChar(ExtractFilePath(Application.ExeName) + 'Project3.exe'));
p := GetProcAddress(hnd, 'TestExport');
p('Ajouté par dll', Memo1);
FreeLibrary(hnd);
end; |
Partager