Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi Form von dll aus schließen. (https://www.delphipraxis.net/126935-form-von-dll-aus-schliessen.html)

k4ni 5. Jan 2009 11:18


Form von dll aus schließen.
 
Hallo,

Ich habe eine dll geschrieben, die man in den prozess injected, und sobald man dies tut dejected diese eine andere dll + sich selber.
Das andere module das sie dejected, ist in diesem falle "cepe.dll", das problem ist nur, dass dieses module auch eine Form erstellt.

Jetzt meine frage: Wie könnte ich diese Form von meiner DLL schließen?
Also ich wills jetzt nicht direkt per FindWindow() suchen denn es kann ja sein das ich diese form öfter offen hab und es mir dann an die falsche geht.
Was ich schon versucht hab:
Delphi-Quellcode:
    lolwat := FindWindowEx(Application.Handle, 0, nil, 'Crappy Packet Editor Doh!');
    if lolwat<> 0 then
      PostMessage(lolwat, WM_QUIT, 0, 0);
Geht aber nicht wirklich =/
Irgend ne idee?

mkinzler 5. Jan 2009 11:20

Re: Form von dll aus schließen.
 
Füge die Funktion ins Interface der Dll ein. Und rufe diese dann auf

k4ni 5. Jan 2009 11:41

Re: Form von dll aus schließen.
 
Ah ok, also ich hab das jetzt mal so versucht:

Bei cepe.dll (die, die ich dejecten will):
Delphi-Quellcode:
interface
...
procedure CloseMyForm(); stdcall;

...

implementation

procedure CloseMyForm; stdcall;
begin
ShowMessage('workd');
end;
Und natürlich
Delphi-Quellcode:
exports CloseMyForm;
Dann die unloader.dll, mit der ich die form von cepe.dll schließen will bzw. die CloseMyForm aufrufen will:
Delphi-Quellcode:
interface
...
type CloseMyForm=procedure; stdcall;

...

 var
   TCF: CloseMyForm;

...

function DllMain(..)
begin
   TCF;
end;
..
Ich denke jetzt mal du hast das so (ähnlich) gemeint, aber geht iwie net :S

Edit:
Oder so ungefähr?
Delphi-Quellcode:
    Hcepe := GetModuleHandle('cepe.dll');
    TCF := GetProcAddress(Hcepe, 'CLoseMyForm');
    TCF;


Alle Zeitangaben in WEZ +1. Es ist jetzt 02:31 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz