Delphi and Kylix

Moderators: pritaeas
Number of threads: 7244
Number of posts: 19051

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
terminate another application Posted by porodoro on 19 May 2006 at 6:46 AM
This message was edited by porodoro at 2006-5-19 6:47:39


Hi ,
i've got a code that terminates an another application.
The problem is , that the other application runs as service and its caption changes all the time , and my
code terminates only if it detects the window name of the service app.

What i want , is to terminate the exename of that application , which is listed in task list (CTRL+ALT+DEL -> LIST #2).
The caption is : "Testprj.exe".

Heres my simple code:

s:=FindWindow(Nil, 'Testprj.exe') ;
PostMessage(s, WM_QUIT, 0, 0) ;
and
s:=FindWindow(Nil, 'Testprj') ;
PostMessage(s, WM_QUIT, 0, 0) ;

but it doesnt work.
Can you help please?

edit---
Also i've searched on google but i couldnt find anything better _

Report
Re: terminate another application Posted by porodoro on 19 May 2006 at 12:47 PM
: This message was edited by porodoro at 2006-5-19 6:47:39

:
: Hi ,
: i've got a code that terminates an another application.
: The problem is , that the other application runs as service and its caption changes all the time , and my
: code terminates only if it detects the window name of the service app.
:
: What i want , is to terminate the exename of that application , which is listed in task list (CTRL+ALT+DEL -> LIST #2).
: The caption is : "Testprj.exe".
:
: Heres my simple code:
:
: s:=FindWindow(Nil, 'Testprj.exe') ;
: PostMessage(s, WM_QUIT, 0, 0) ;
: and
: s:=FindWindow(Nil, 'Testprj') ;
: PostMessage(s, WM_QUIT, 0, 0) ;
:
: but it doesnt work.
: Can you help please?
:
: edit---
: Also i've searched on google but i couldnt find anything better _
:
:
after hours searching , i found out that i have to find the classname.
Any info for this?

Report
Re: terminate another application Posted by !Rebel! on 19 May 2006 at 1:56 PM
Hi,

You'll get class name by GetClassName function:

GetClassName(hWnd: HWND; lpClassName: PChar; nMaxCount: Integer);

hWnd: the Handle you've got by FindWindow.
lpClassName: points to the buffer that is to receive the class name string.
nMaxCount: max. Length of the Result in lpClassName.
Report
Re: terminate another application Posted by zibadian on 19 May 2006 at 2:12 PM
: Hi,
:
: You'll get class name by GetClassName function:
:
: GetClassName(hWnd: HWND; lpClassName: PChar; nMaxCount: Integer);
:
: hWnd: the Handle you've got by FindWindow.
: lpClassName: points to the buffer that is to receive the class name string.
: nMaxCount: max. Length of the Result in lpClassName.
:
Now the problem is still: how to get the hWnd value, since FindWindow() cannot find the correct window?
Report
Re: terminate another application Posted by !Rebel! on 19 May 2006 at 11:32 PM
Hi,

Check out these functions:
OpenSCManager: it gives you a handle to Service Manager
GetServiceKeyName: to obtain the service' real name by its display name
OpenService: it gives you the handle by its name
ControlService, CloseService, DeleteService

I hope this is what you need.

bw
Rebel
Report
Re: terminate another application Posted by porodoro on 20 May 2006 at 10:00 AM
: Hi,
:
: Check out these functions:
: OpenSCManager: it gives you a handle to Service Manager
: GetServiceKeyName: to obtain the service' real name by its display name
: OpenService: it gives you the handle by its name
: ControlService, CloseService, DeleteService
:
: I hope this is what you need.
:
: bw
: Rebel
:
Thanks , i found it ..

Just one thing , how can i set the proccess priority ? (i've found the window name - i just need an example how to do this)
Thanks!!



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.