Autor Beitrag
bis11
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1247
Erhaltene Danke: 2

Apple Mac OSX 10.11

BeitragVerfasst: Mo 17.01.05 19:51 
Hallo Leutz,

ich habe da mal wieder ein Problem. Ich habe eine Form in eine DLL gepackt, die ich mit folgender procedure in der DLL aufrufe :

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
procedure configuration(appHandle: THandle); stdcall;
begin
  if appHandle = 0 then apphandle := GetActiveWindow;
  Application.Handle := appHandle;
  try
    with TConfiguration_Main.Create(Application) Do
      try
        ShowModal
      finally
        Free;
      end
  except
    On E: Exception Do Application.HandleException(E);
  end;
  Application.Handle := 0;
end;


Wenn ich die DLL nicht dynamisch einbinde, funktioniert alles wunderbar. Nur wenn ich die DLL zur Laufzeit mit der folgenden OnClick-Routine aufrufen will, wird die Form nicht angezeigt.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
procedure TMainControl.Configuration_btnClick(Sender: TObject);
var
   hDLL : THandle;
   ConfigWindow : TConfigWindow;
begin
   hDLL := LoadLibrary(PChar(ExtractFilePath(ParamStr(0))+'config.dll'));
   if hDLL <> 0 then begin
     try
       GetProcAddress(hDLL, 'configuration');
     finally
       FreeLibrary(hDLL);
     end;
   end;
end;


Es erscheint kein Fehler oder sonstiges. Was mache ich hier verkehrt und warum ist das verkehrt ? Kommt mir bitte nicht mit dem Vorschlag die trotzdem nicht dynamisch einzubinden, weil ich sonst jede DLL so einbinden müsste. Denn ich möchte eine Art Baukastensystem dadurch erreichen. Für andere Vorschläge bin ich natürlich offen um ein Baukastensystem von meinem Programm zu machen.
Bernhard Geyer
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 721
Erhaltene Danke: 3



BeitragVerfasst: Mo 17.01.05 20:04 
Mit
ausblenden Delphi-Quelltext
1:
GetProcAddress(hDLL, 'configuration');					

ruft du nicht die Funktion auf, sondern läßt dir einen Funktionszeiger geben.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
type
  TMyFuncProc = procedure(appHandle: THandle); stdcall;

var
  MyFuncProc: TMyFuncProc;

...

  MyFuncProc := GetProcAddress(hDLL, 'configuration');   // <- Hier holst Du dir den Funktionszeiger für deine Prozedur
  MyFuncProc(Application.Handle);                        // <- Hier wird die Funktion aufgerufen!!!
...
bis11 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1247
Erhaltene Danke: 2

Apple Mac OSX 10.11

BeitragVerfasst: Mo 17.01.05 20:49 
Hallo Bernhard,

ich danke Dir für Deine Antwort. Es hat hervorragend funktionniert.