terminate another application - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

terminate another application

porodoroporodoro Posts: 230Member
[b][red]This message was edited by porodoro at 2006-5-19 6:47:39[/red][/b][hr]

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 _

Comments

  • porodoroporodoro Posts: 230Member
    : [b][red]This message was edited by porodoro at 2006-5-19 6:47:39[/red][/b][hr]
    :
    : 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?

  • !Rebel!!Rebel! Posts: 4Member
    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.
  • zibadianzibadian Posts: 6,349Member
    : 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?
  • !Rebel!!Rebel! Posts: 4Member
    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
  • porodoroporodoro Posts: 230Member
    : 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!!
Sign In or Register to comment.