Click here to Skip to main content
16,011,743 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Dialog context help button Pin
PJ Arends20-Mar-02 21:13
professionalPJ Arends20-Mar-02 21:13 
GeneralRe: Dialog context help button Pin
alex.barylski20-Mar-02 21:22
alex.barylski20-Mar-02 21:22 
GeneralRe: Dialog context help button Pin
PJ Arends20-Mar-02 21:48
professionalPJ Arends20-Mar-02 21:48 
GeneralRe: Dialog context help button Pin
alex.barylski20-Mar-02 21:55
alex.barylski20-Mar-02 21:55 
QuestionHow to terminate/close an application launched by ShellExecute ? Pin
20-Mar-02 18:44
suss20-Mar-02 18:44 
AnswerRe: How to terminate/close an application launched by ShellExecute ? Pin
Prem Kumar20-Mar-02 19:58
Prem Kumar20-Mar-02 19:58 
AnswerRe: How to terminate/close an application launched by ShellExecute ? Pin
Nish Nishant20-Mar-02 21:28
sitebuilderNish Nishant20-Mar-02 21:28 
AnswerRe: How to terminate/close an application launched by ShellExecute ? Pin
Joaquín M López Muñoz20-Mar-02 22:04
Joaquín M López Muñoz20-Mar-02 22:04 
The HINSTANCE returned by ShellExecute is not a valid handle to anything, it is there for compatibility reasons. To obtain a true handle to the launched process, use ShellExecuteEx. Nevertheless, for the purposes of closing the process, it is better to have the process ID, which you can obtain easily if you launch the program with CreateProcess (retrieving the process ID from a process handle is alas no easy task). Given the process ID of the program you wish to close, use EnumWindows to enumerate all top level windows and proceed as follows for each HWND enumerated:
  1. Use GetWindowThreadProcessId to retrieve the process ID of the window.
  2. If the process ID matches the one you got, then send a WM_CLOSE message to that window.
For added robustness, you might consider using SendMessageTimeout and, if the polite way of closing the app doesn't work, getting a process handle with OpenProcess and calling TerminateProcess to force the app shut.

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
Generalexecuting older version application in new version Pin
Bhikshapathi Gorantla20-Mar-02 18:16
Bhikshapathi Gorantla20-Mar-02 18:16 
GeneralRe: executing older version application in new version Pin
Tomasz Sowinski20-Mar-02 22:31
Tomasz Sowinski20-Mar-02 22:31 
GeneralCPP C# Pin
20-Mar-02 18:16
suss20-Mar-02 18:16 
GeneralRe: CPP C# Pin
Tomasz Sowinski20-Mar-02 22:44
Tomasz Sowinski20-Mar-02 22:44 
GeneralBaffling Thread problem Pin
MarkPQ20-Mar-02 18:12
MarkPQ20-Mar-02 18:12 
GeneralRe: Baffling Thread problem Pin
Vivek Rajan20-Mar-02 18:57
Vivek Rajan20-Mar-02 18:57 
GeneralRe: Baffling Thread problem Pin
MarkPQ20-Mar-02 19:13
MarkPQ20-Mar-02 19:13 
GeneralRe: Baffling Thread problem Pin
Tomasz Sowinski20-Mar-02 22:34
Tomasz Sowinski20-Mar-02 22:34 
GeneralRe: Baffling Thread problem Pin
MarkPQ21-Mar-02 15:20
MarkPQ21-Mar-02 15:20 
GeneralWriting to a file.. Pin
Neha20-Mar-02 17:44
Neha20-Mar-02 17:44 
GeneralRe: Writing to a file.. Pin
Paul M Watt20-Mar-02 17:54
mentorPaul M Watt20-Mar-02 17:54 
GeneralRe: Writing to a file.. Pin
Neha20-Mar-02 18:14
Neha20-Mar-02 18:14 
GeneralRe: Writing to a file.. Pin
Neha20-Mar-02 19:42
Neha20-Mar-02 19:42 
General#pragma Pin
bryce20-Mar-02 17:09
bryce20-Mar-02 17:09 
General#pragma warning( disable : 4006) Pin
Paul M Watt20-Mar-02 17:29
mentorPaul M Watt20-Mar-02 17:29 
GeneralRe: #pragma warning( disable : 4006)-Nope Pin
bryce20-Mar-02 17:34
bryce20-Mar-02 17:34 
GeneralRe: #pragma warning( disable : 4006)-Nope Pin
Paul M Watt20-Mar-02 17:49
mentorPaul M Watt20-Mar-02 17:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.