Autor Beitrag
Xelos
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 21



BeitragVerfasst: Sa 28.09.02 14:46 
Hi :)
hätte wer nen Tip, wie ich eine fremde Anwendung (z.B. den Taschenrechner von Win) mit einem Delphi Prog beenden kann?

Thx schonmal für die Mühe.

Gruss
Xelos
DeCodeGuru
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1333
Erhaltene Danke: 1

Arch Linux
Eclipse
BeitragVerfasst: Sa 28.09.02 15:02 
Hi,

dafür brauchst du erstmal das Handle des Programms, welches du über FindWindow rausbekommst.

PSDK ( :mrgreen: ):
Zitat:
The FindWindow function retrieves a handle to the top-level window whose class name and window name match the specified strings. This function does not search child windows. This function does not perform a case-sensitive search.

To search child windows, beginning with a specified child window, use the FindWindowEx function.


Syntax

ausblenden Quelltext
1:
2:
3:
HWND FindWindow(          LPCTSTR lpClassName,
    LPCTSTR lpWindowName
);


Parameters

lpClassName
[in] Pointer to a null-terminated string that specifies the class name or a class atom created by a previous call to the RegisterClass or RegisterClassEx function. The atom must be in the low-order word of lpClassName; the high-order word must be zero.
If lpClassName points to a string, it specifies the window class name. The class name can be any name registered with RegisterClass or RegisterClassEx, or any of the predefined control-class names.

If lpClassName is NULL, it finds any window whose title matches the lpWindowName parameter.

lpWindowName
[in] Pointer to a null-terminated string that specifies the window name (the window's title). If this parameter is NULL, all window names match.

Return Value

If the function succeeds, the return value is a handle to the window that has the specified class name and window name.

If the function fails, the return value is NULL. To get extended error information, call GetLastError.


Wenn du das Handle hast, kannst du mit SendMessage Botschaften an das handle schicken. Zum Beenden kannst du WM_Close, WM_Quit, WM_Destroy verwenden. WM_Close sagt dem Fenster, dass es sich beenden soll, was es aber zum Beispiel nicht macht, wenn es sich um einen Button handelt etc... WM_Quit ist etwas direkter. Damit kannste eigentlich jedes Fenster schließen. Ja und WM_Destroy ist die etwas harte Tour, mit der man alles beenden dürfte :wink:

Ein kleines Tipp: Verwenden am Besten WM_Close, weil das programm ja auch noch Zeit haben soll, seine variable freizugeben etc...

_________________
Viele Grüße
Jakob
Ex0rzist
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 550

Win XP Prof.
Mandrake 10.0

D6
BeitragVerfasst: Sa 28.09.02 15:04 
Guckst du hier. :wink:


Gruß
___________

Ex0rzist
MathiasSimmack
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Sa 28.09.02 15:27 
Ex0rzist hat folgendes geschrieben:
Guckst du [url=www.auq.de/viewtopic.php?t=221]hier[/url].

Und wenn er Nein sagt? :?

@DeCodeGuru: Ich würde noch einsehen, wenn du neue API-Befehle samt Erklärung postest. Aber sowohl "findwindow" als auch "ShowWindow" sind so alt, dass selbst die Borland-Hilfedatei was dazu weiß.
Xelos Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 21



BeitragVerfasst: Sa 28.09.02 15:33 
Mein lieber Scholli *g*
ihr habt wohl schon auf meine Frage gewartet, das Ihr so schnell ne Antwort parat habt.

Aus euren beiden Beiträgen ergibt sich folgende Zeile:
ausblenden Quelltext
1:
PostMessage(FindWindow(nil,pchar('Rechner')),WM_CLOSE,0, 0);					

und dem geht *froi*

Much Thxi

Xelos
Ex0rzist
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 550

Win XP Prof.
Mandrake 10.0

D6
BeitragVerfasst: Sa 28.09.02 15:38 
MathiasSimmack hat folgendes geschrieben:
Ex0rzist hat folgendes geschrieben:
Guckst du [url=www.auq.de/viewtopic.php?t=221]hier[/url].

Und wenn er Nein sagt? :?


Dann hat er kein Interesse an der Lösung seines Problems. :wink:

Gruß
_________

Ex0rzist
DeCodeGuru
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1333
Erhaltene Danke: 1

Arch Linux
Eclipse
BeitragVerfasst: Sa 28.09.02 16:50 
Zitat:
@DeCodeGuru: Ich würde noch einsehen, wenn du neue API-Befehle samt Erklärung postest. Aber sowohl "findwindow" als auch "ShowWindow" sind so alt, dass selbst die Borland-Hilfedatei was dazu weiß.


Gut, ok, hast recht, nehme alles zurück udn jetzt stelle ich mich in eine Ecke und schäme mich :oops:

_________________
Viele Grüße
Jakob