Click here to Skip to main content
14,660,427 members
Home » Discussions » C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Assertion From SendNotifyMessage Pin
Richard MacCutchan25-Feb-16 6:31
mveRichard MacCutchan25-Feb-16 6:31 
QuestionUsing ShellExecute or CreateProcess caller lose its focus Pin
sdancer7523-Feb-16 8:30
Membersdancer7523-Feb-16 8:30 
AnswerRe: Using ShellExecute or CreateProcess caller lose its focus Pin
Richard Andrew x6423-Feb-16 10:22
professionalRichard Andrew x6423-Feb-16 10:22 
GeneralRe: Using ShellExecute or CreateProcess caller lose its focus Pin
sdancer7523-Feb-16 20:29
Membersdancer7523-Feb-16 20:29 
GeneralRe: Using ShellExecute or CreateProcess caller lose its focus Pin
Richard MacCutchan23-Feb-16 21:17
mveRichard MacCutchan23-Feb-16 21:17 
GeneralRe: Using ShellExecute or CreateProcess caller lose its focus Pin
sdancer7524-Feb-16 0:56
Membersdancer7524-Feb-16 0:56 
GeneralRe: Using ShellExecute or CreateProcess caller lose its focus Pin
Victor Nijegorodov24-Feb-16 1:06
MemberVictor Nijegorodov24-Feb-16 1:06 
GeneralRe: Using ShellExecute or CreateProcess caller lose its focus Pin
sdancer7524-Feb-16 1:12
Membersdancer7524-Feb-16 1:12 
Hi,

No problem at all, I just gave all the code in the link. Anyway, I attach you the most important code from the sample app.

void CMainFrame::OnRunExternalApp() {


	SHELLEXECUTEINFO	lpExecInfo;
	PROCESS_INFORMATION processInfo;
	DWORD				dwExitCode;
	HANDLE				hProcess = 0;
	BOOL				bResult;
	LPTSTR				strCmd;





	strCmd = _T("");

	//bResult = StartupApplicationWithShell (_T("LiveUpdate.exe"), (LPTSTR)strCmd,  GetSafeHwnd(), &hProcess);
	bResult = StartupApplicationWithProcess (_T("C:\\Windows\\notepad.exe"), (LPTSTR)strCmd,  &processInfo);

	EnableWindow(FALSE);



	if(bResult) { //(UINT)result > HINSTANCE_ERROR)
	
		//ShowWindow( SW_HIDE );
		//ShowWindow( SW_SHOWNOACTIVATE );
		
	
	    //WaitForSingleObject( hProcess, INFINITE );
		WaitForSingleObject(processInfo.hProcess, INFINITE);
		//WaitForMultipleObjects(1, &processInfo.hThread, TRUE, INFINITE );

	

		   
		//if (!GetExitCodeProcess(hProcess, &dwExitCode)) {
		//	   	AMLOGINFO(_T("LiveUpdate is not terminated normally.")); 
		//}
		if (!GetExitCodeProcess(processInfo.hProcess, &dwExitCode)) {
			   	//failed
		}
		CloseHandle( processInfo.hProcess );
        CloseHandle( processInfo.hThread );
		//CloseHandle(hProcess);
 

	} else {
		
		// failed
	}

	BringWindowToTop();
	EnableWindow(TRUE);
	
	//UpdateWindow();

	//::SetWindowPos( GetSafeHwnd(), HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW );
}

sdancer75

GeneralRe: Using ShellExecute or CreateProcess caller lose its focus Pin
Victor Nijegorodov24-Feb-16 1:29
MemberVictor Nijegorodov24-Feb-16 1:29 
GeneralRe: Using ShellExecute or CreateProcess caller lose its focus Pin
sdancer7524-Feb-16 1:35
Membersdancer7524-Feb-16 1:35 
GeneralRe: Using ShellExecute or CreateProcess caller lose its focus Pin
Victor Nijegorodov24-Feb-16 2:07
MemberVictor Nijegorodov24-Feb-16 2:07 
GeneralRe: Using ShellExecute or CreateProcess caller lose its focus Pin
sdancer7524-Feb-16 2:20
Membersdancer7524-Feb-16 2:20 
GeneralRe: Using ShellExecute or CreateProcess caller lose its focus Pin
sdancer7524-Feb-16 2:31
Membersdancer7524-Feb-16 2:31 
GeneralRe: Using ShellExecute or CreateProcess caller lose its focus Pin
Victor Nijegorodov24-Feb-16 5:29
MemberVictor Nijegorodov24-Feb-16 5:29 
AnswerRe: Using ShellExecute or CreateProcess caller lose its focus Pin
Jochen Arndt23-Feb-16 23:05
professionalJochen Arndt23-Feb-16 23:05 
GeneralRe: Using ShellExecute or CreateProcess caller lose its focus Pin
sdancer7524-Feb-16 0:55
Membersdancer7524-Feb-16 0:55 
GeneralRe: Using ShellExecute or CreateProcess caller lose its focus Pin
Jochen Arndt24-Feb-16 1:42
professionalJochen Arndt24-Feb-16 1:42 
GeneralRe: Using ShellExecute or CreateProcess caller lose its focus Pin
sdancer7524-Feb-16 2:15
Membersdancer7524-Feb-16 2:15 
GeneralRe: Using ShellExecute or CreateProcess caller lose its focus Pin
Jochen Arndt24-Feb-16 2:20
professionalJochen Arndt24-Feb-16 2:20 
GeneralRe: Using ShellExecute or CreateProcess caller lose its focus Pin
sdancer7524-Feb-16 2:28
Membersdancer7524-Feb-16 2:28 
GeneralRe: Using ShellExecute or CreateProcess caller lose its focus Pin
Jochen Arndt24-Feb-16 2:38
professionalJochen Arndt24-Feb-16 2:38 
GeneralRe: Using ShellExecute or CreateProcess caller lose its focus Pin
sdancer7524-Feb-16 2:43
Membersdancer7524-Feb-16 2:43 
GeneralRe: Using ShellExecute or CreateProcess caller lose its focus Pin
Jochen Arndt24-Feb-16 2:54
professionalJochen Arndt24-Feb-16 2:54 
GeneralRe: Using ShellExecute or CreateProcess caller lose its focus Pin
sdancer7524-Feb-16 6:50
Membersdancer7524-Feb-16 6:50 
AnswerRe: Using ShellExecute or CreateProcess caller lose its focus Pin
Victor Nijegorodov23-Feb-16 23:23
MemberVictor Nijegorodov23-Feb-16 23:23 

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.