Click here to Skip to main content
15,886,422 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionOpen other Application From Dialogue Pin
camuoi28817-May-11 22:59
camuoi28817-May-11 22:59 
AnswerRe: Open other Application From Dialogue Pin
Richard MacCutchan17-May-11 23:22
mveRichard MacCutchan17-May-11 23:22 
GeneralRe: Open other Application From Dialogue Pin
camuoi28817-May-11 23:48
camuoi28817-May-11 23:48 
GeneralRe: Open other Application From Dialogue Pin
Richard MacCutchan18-May-11 1:19
mveRichard MacCutchan18-May-11 1:19 
AnswerRe: Open other Application From Dialogue Pin
వేంకటనారాయణ(venkatmakam)17-May-11 23:30
వేంకటనారాయణ(venkatmakam)17-May-11 23:30 
AnswerRe: Open other Application From Dialogue Pin
Legor17-May-11 23:31
Legor17-May-11 23:31 
GeneralRe: Open other Application From Dialogue Pin
camuoi28817-May-11 23:43
camuoi28817-May-11 23:43 
AnswerRe: Open other Application From Dialogue Pin
ShilpiP18-May-11 1:55
ShilpiP18-May-11 1:55 
Simple Example of CreateProcess
//Global Variable
DWORD g_nRetVal = 0;
DWORD g_nWaitCode = 0;
HANDLE g_hWaited = NULL;

DWORD WINAPI RunUtils(void *pParam) { 
	LPCTSTR szExe = TEXT("Path of executable");
	LPTSTR szParams = TEXT(" /d C:");
	HANDLE hEvent = NULL;
	PROCESS_INFORMATION ProcessInfo;
	ZeroMemory(&ProcessInfo, sizeof(ProcessInfo));
	STARTUPINFO StartupInfo;
	ZeroMemory(&StartupInfo, sizeof(StartupInfo));
	StartupInfo.cb = sizeof(StartupInfo);
	StartupInfo.dwFlags = STARTF_USESHOWWINDOW;
	StartupInfo.wShowWindow = SW_HIDE;
	hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
	if (CreateProcess(szExe, szParams, NULL, NULL, FALSE, CREATE_NEW_CONSOLE, NULL, NULL, &StartupInfo, &ProcessInfo)) {
		g_nWaitCode = WaitForSingleObject(ProcessInfo.hProcess, INFINITE);
		switch (g_nWaitCode) {
			case WAIT_OBJECT_0:
				GetExitCodeProcess(ProcessInfo.hProcess, &g_nRetVal);
				break;

			case WAIT_FAILED:
				g_nWaitCode = GetLastError();
				break;
		}
		::CloseHandle(ProcessInfo.hProcess);
		::CloseHandle(ProcessInfo.hThread);
		
		ResetEvent(hEvent);

		HWND hWnd = (HWND) pParam;
		SendMessage(hWnd, WM_USER_THREAD_WAITED, 0, 0);
	}
	return 0;
}

void CThunghiemDlg::OnButtonOpen()
{
	// TODO: Add your control notification handler code here
	HANDLE hExecThread = NULL;
	if(m_bCleanUp)
	{
		hExecThread = CreateThread(NULL, 0, &RunUtils, (LPVOID) m_hWnd, 0, NULL);
	}
}


You can do the same by using ShellExecute
void CThunghiemDlg::OnButtonOpen() 
{
	ShellExecute(NULL, "open", "path of executable", NULL, NULL, SW_SHOWNORMAL);	
	
}

"Every Little Smile can touch Somebody's Heart...
May we find Hundreds of Reasons to Smile Everyday... and
May WE be the Reason for someone else to smile always!" (ICAN)

GeneralRe: Open other Application From Dialogue Pin
camuoi28818-May-11 17:06
camuoi28818-May-11 17:06 
GeneralRe: Open other Application From Dialogue Pin
ShilpiP18-May-11 18:40
ShilpiP18-May-11 18:40 
Questionaccessing the document object model of any window in win32 api or .net Pin
Jayapal Chandran17-May-11 22:35
Jayapal Chandran17-May-11 22:35 
QuestionRe: accessing the document object model of any window in win32 api or .net Pin
Abhi Lahare18-May-11 6:17
Abhi Lahare18-May-11 6:17 
AnswerRe: accessing the document object model of any window in win32 api or .net Pin
Jayapal Chandran18-May-11 13:55
Jayapal Chandran18-May-11 13:55 
GeneralRe: accessing the document object model of any window in win32 api or .net Pin
Abhi Lahare19-May-11 8:43
Abhi Lahare19-May-11 8:43 
QuestionReadFile () reads Junk characters when tried to read from COM1 Port Pin
pandit8417-May-11 3:34
pandit8417-May-11 3:34 
QuestionRe: ReadFile () reads Junk characters when tried to read from COM1 Port Pin
David Crow17-May-11 3:50
David Crow17-May-11 3:50 
AnswerRe: ReadFile () reads Junk characters when tried to read from COM1 Port Pin
pandit8417-May-11 3:55
pandit8417-May-11 3:55 
GeneralRe: ReadFile () reads Junk characters when tried to read from COM1 Port Pin
barneyman17-May-11 4:01
barneyman17-May-11 4:01 
GeneralRe: ReadFile () reads Junk characters when tried to read from COM1 Port Pin
pandit8417-May-11 4:04
pandit8417-May-11 4:04 
GeneralRe: ReadFile () reads Junk characters when tried to read from COM1 Port [modified] Pin
barneyman17-May-11 4:10
barneyman17-May-11 4:10 
QuestionRe: ReadFile () reads Junk characters when tried to read from COM1 Port Pin
David Crow17-May-11 4:03
David Crow17-May-11 4:03 
AnswerMessage Removed Pin
17-May-11 4:05
pandit8417-May-11 4:05 
QuestionRe: ReadFile () reads Junk characters when tried to read from COM1 Port Pin
David Crow17-May-11 4:13
David Crow17-May-11 4:13 
AnswerRe: ReadFile () reads Junk characters when tried to read from COM1 Port Pin
pandit8417-May-11 4:16
pandit8417-May-11 4:16 
QuestionRe: ReadFile () reads Junk characters when tried to read from COM1 Port Pin
David Crow17-May-11 4:38
David Crow17-May-11 4:38 

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.