Click here to Skip to main content
15,889,315 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionNetwork Management Pin
dharani20-May-07 21:27
dharani20-May-07 21:27 
AnswerRe: Network Management Pin
Hamid_RT20-May-07 22:10
Hamid_RT20-May-07 22:10 
QuestionCreateProcess problem. Pin
david bagaturia20-May-07 21:00
david bagaturia20-May-07 21:00 
AnswerRe: CreateProcess problem. Pin
dharani20-May-07 21:15
dharani20-May-07 21:15 
GeneralRe: CreateProcess problem. Pin
david bagaturia20-May-07 21:20
david bagaturia20-May-07 21:20 
GeneralRe: CreateProcess problem. Pin
dharani20-May-07 21:28
dharani20-May-07 21:28 
GeneralRe: CreateProcess problem. Pin
david bagaturia20-May-07 21:33
david bagaturia20-May-07 21:33 
AnswerRe: CreateProcess problem. Pin
Stephen Hewitt20-May-07 21:51
Stephen Hewitt20-May-07 21:51 
Will this even compile? Look at the last two arguments to CreateProcess.

Lose the try/catch blocks; CreateProcess doesn't throw exceptions to indicate errors and any exceptions it does throw (such as access violations) will almost certainly be your fault and should be allowed to propergate to the debugger so the problem can be fixed. I’ll gloss over the issue that the fact that try/catch can even catch access violations (and other such exceptions) is non-standard and later MS compilers have been fixed in this regard (although the old buggy behaviour can be re-enabled via a compiler switch).

Here's an example:
// Win32App.cpp : Defines the entry point for the application.
//
 
#include "stdafx.h"
 
int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
	STARTUPINFO si = {0};
	si.cb = sizeof(si);
	si.lpTitle = "Use this as the title!";
 
	PROCESS_INFORMATION pi;
 	BOOL bOK = CreateProcess(
			"C:\\Commands\\AnyKey.exe",
			NULL,
			NULL,
			NULL,
			FALSE,
			CREATE_NEW_CONSOLE,
			NULL,
			NULL,
			&si,
			&pi
			);
	if (bOK)
	{
		// If 'CreateProcess' succeeds the HANDLES in 'pi' should be closed unless you need them.
		// Failing to close them results in resource leaks!
		CloseHandle(pi.hProcess);
		CloseHandle(pi.hThread);
	}
 
	return 0;
}


Steve

GeneralRe: CreateProcess problem. Pin
david bagaturia20-May-07 22:46
david bagaturia20-May-07 22:46 
QuestionMotion Detection in VC++ Pin
tyagineha20-May-07 20:02
tyagineha20-May-07 20:02 
AnswerRe: Motion Detection in VC++ Pin
bankai12320-May-07 21:59
bankai12320-May-07 21:59 
GeneralRe: Motion Detection in VC++ Pin
tyagineha20-May-07 22:35
tyagineha20-May-07 22:35 
AnswerRe: Motion Detection in VC++ Pin
Hamid_RT22-May-07 19:23
Hamid_RT22-May-07 19:23 
QuestionDisable sounds Pin
rrrado20-May-07 19:53
rrrado20-May-07 19:53 
AnswerRe: Disable sounds Pin
Hamid_RT20-May-07 20:09
Hamid_RT20-May-07 20:09 
GeneralRe: Disable sounds Pin
rrrado20-May-07 20:12
rrrado20-May-07 20:12 
GeneralRe: Disable sounds Pin
David Crow21-May-07 3:36
David Crow21-May-07 3:36 
AnswerRe: Disable sounds Pin
zhang80060520-May-07 20:59
zhang80060520-May-07 20:59 
GeneralRe: Disable sounds Pin
rrrado20-May-07 21:26
rrrado20-May-07 21:26 
GeneralRe: Disable sounds Pin
zhang80060521-May-07 0:10
zhang80060521-May-07 0:10 
GeneralRe: Disable sounds Pin
rrrado21-May-07 22:21
rrrado21-May-07 22:21 
QuestionHow to get word capture from another application using hooks concepts? Pin
A.Venkata ramana20-May-07 19:27
A.Venkata ramana20-May-07 19:27 
QuestionRe: How to get word capture from another application using hooks concepts? Pin
Rajesh R Subramanian20-May-07 20:01
professionalRajesh R Subramanian20-May-07 20:01 
QuestionSoftware failing when distributed Pin
Stick^20-May-07 18:00
Stick^20-May-07 18:00 
AnswerRe: Software failing when distributed Pin
rrrado20-May-07 20:17
rrrado20-May-07 20:17 

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.