I am using Delphi XE, I have the following setup:
Both Mydll.dll and Package1.bpl (runtime package) contain Unit3.pas
unit Unit3;
interface
implementation
uses Dialogs;
procedure TestProc(const S: string); stdcall;
begin
MessageDlg(S, mtInformation, [mbOK], 0);
end;
exports TestProc;
end.
Case 1:
procedure TestProc(const S: string); stdcall; external 'mydll.dll';
procedure TForm1.Button3Click(Sender: TObject);
begin
TestProc('Button3');
end;
Case 2:
procedure TestProc(const S: string); stdcall; external 'Package1.bpl';
procedure TForm1.Button3Click(Sender: TObject);
begin
TestProc('Button3');
end;
Case 3:
procedure TForm1.Button3Click(Sender: TObject);
var H: THandle;
P: procedure(const S: string); stdcall;
begin
H := LoadPackage('Package1.bpl');
try
@P := GetProcAddress(H, PChar('TestProc'));
if Assigned(P) then
P('Button3');
finally
UnloadPackage(H);
end;
end;
Case 1 and Case 3 have passed , but Case 2 will increase access to the violation .
My question, as shown below, is
1. Case 2 not supported?
2. Except in case 3, is there anyway a call to TestProc from Package1.bpl similarly to Case1?
source
share