Click here to Skip to main content
15,906,645 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How I will write a macro to check............................ Pin
deadlyabbas7-Sep-09 1:40
deadlyabbas7-Sep-09 1:40 
GeneralRe: How I will write a macro to check............................ Pin
Stuart Dootson7-Sep-09 2:55
professionalStuart Dootson7-Sep-09 2:55 
AnswerRe: How I will write a macro to check............................ Pin
Chris Losinger7-Sep-09 3:47
professionalChris Losinger7-Sep-09 3:47 
Questionvisual C++ expert...need help!! Pin
mr bard26-Sep-09 23:30
mr bard26-Sep-09 23:30 
AnswerRe: visual C++ expert...need help!! Pin
Cedric Moonen6-Sep-09 23:59
Cedric Moonen6-Sep-09 23:59 
GeneralRe: visual C++ expert...need help!! Pin
mr bard28-Sep-09 19:51
mr bard28-Sep-09 19:51 
AnswerRe: visual C++ expert...need help!! Pin
Richard MacCutchan8-Sep-09 23:03
mveRichard MacCutchan8-Sep-09 23:03 
QuestionTerminating Process [modified] Pin
gothic_coder6-Sep-09 21:42
gothic_coder6-Sep-09 21:42 
Hello all..

I'm making an application which terminate other processes in different way, i.e using TerminateProcess, WM_CLOSE, WM_QUIT, SC_CLOSE.

Now i'm able to terminate process in all the way, But i need bit explanation in WM_CLOSE, WM_QUIT and SC_CLOSE.. How exactly it closes other process?? I believe there are two conditions which need to be fulfilled.
1> The target process has at least one window.
2> The target process doesn't handle the WM_CLOSE, WM_QUIT, SC_CLOSE message.

So i'm doing this to enumerates all top level windows, In LPARAM i'm passing the pid of the target process..
EnumWindows((WNDENUMPROC)Enum_Terminate_Process, (LPARAM) aiPID[i]);


And in Enum_Terminate_Process, I'm doing something like this..

BOOL CALLBACK Enum_Terminate_Process(HWND hWnd, LPARAM lParam)
{
	DWORD dwID;

	GetWindowThreadProcessId(hWnd, &dwID);
	
	if(dwID == (DWORD)lParam)
	{
                char Title[MAX_PATH];

		Title[0] = 0;
		GetWindowText(hWnd, Title, sizeof(Title));

		if(IsWindowEnabled(hWnd) && Title[0]!= 0 && Proc_Argument[0]!= 0)
		{
                        if(strcmp(Proc_Argument , "-wmc") == 0)
				SendMessage(hWnd, WM_CLOSE, 0, 0 );
			else if(strcmp(Proc_Argument , "-wmq") == 0)
				PostMessage(hWnd, WM_QUIT, 0, 0);
			else if(strcmp(Proc_Argument, "-scl") == 0)
				PostMessage(hWnd, WM_SYSCOMMAND,SC_CLOSE,0);
			else
				MessageBox(NULL,"Invalid Arguments", "Error", MB_OK);				
		}
	}

	return TRUE;
}


So i need to know whether i'm doing right?


Thanks All..

modified on Monday, September 7, 2009 4:39 AM

AnswerRe: Terminating Process Pin
Richard MacCutchan7-Sep-09 2:26
mveRichard MacCutchan7-Sep-09 2:26 
GeneralRe: Terminating Process Pin
gothic_coder7-Sep-09 2:46
gothic_coder7-Sep-09 2:46 
GeneralRe: Terminating Process Pin
kilt7-Sep-09 4:58
kilt7-Sep-09 4:58 
GeneralRe: Terminating Process Pin
Richard MacCutchan7-Sep-09 5:02
mveRichard MacCutchan7-Sep-09 5:02 
GeneralRe: Terminating Process Pin
David Crow14-Sep-09 3:56
David Crow14-Sep-09 3:56 
QuestionHow can set focus in Main window in SDI? Pin
Le@rner6-Sep-09 21:30
Le@rner6-Sep-09 21:30 
AnswerRe: How can set focus in Main window in SDI? Pin
Stuart Dootson6-Sep-09 22:01
professionalStuart Dootson6-Sep-09 22:01 
Questionconst TCHAR* to TCHAR* Pin
Nandu_77b6-Sep-09 21:02
Nandu_77b6-Sep-09 21:02 
AnswerRe: const TCHAR* to TCHAR* Pin
CPallini6-Sep-09 21:10
mveCPallini6-Sep-09 21:10 
AnswerRe: const TCHAR* to TCHAR* Pin
Stuart Dootson6-Sep-09 21:53
professionalStuart Dootson6-Sep-09 21:53 
GeneralRe: const TCHAR* to TCHAR* Pin
Nandu_77b7-Sep-09 1:58
Nandu_77b7-Sep-09 1:58 
QuestionDisplay Strings Pin
Nick_1116-Sep-09 20:28
Nick_1116-Sep-09 20:28 
AnswerRe: Display Strings Pin
Stuart Dootson6-Sep-09 21:50
professionalStuart Dootson6-Sep-09 21:50 
GeneralRe: Display Strings Pin
Nick_1116-Sep-09 22:56
Nick_1116-Sep-09 22:56 
GeneralRe: Display Strings Pin
Stuart Dootson6-Sep-09 23:07
professionalStuart Dootson6-Sep-09 23:07 
GeneralRe: Display Strings Pin
Nick_1116-Sep-09 23:51
Nick_1116-Sep-09 23:51 
GeneralRe: Display Strings Pin
Stuart Dootson6-Sep-09 23:59
professionalStuart Dootson6-Sep-09 23:59 

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.