Click here to Skip to main content
15,918,808 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: inp( ) and outp( ) functions Pin
Mohammad Rastkar20-Sep-06 19:09
Mohammad Rastkar20-Sep-06 19:09 
GeneralRe: inp( ) and outp( ) functions Pin
David Crow21-Sep-06 4:00
David Crow21-Sep-06 4:00 
AnswerRe: inp( ) and outp( ) functions Pin
susiriss20-Sep-06 19:04
susiriss20-Sep-06 19:04 
QuestionRe: inp( ) and outp( ) functions Pin
vijay_aroli20-Sep-06 19:11
vijay_aroli20-Sep-06 19:11 
AnswerRe: inp( ) and outp( ) functions Pin
susiriss20-Sep-06 22:04
susiriss20-Sep-06 22:04 
QuestionRe: inp( ) and outp( ) functions [modified] Pin
vijay_aroli20-Sep-06 23:50
vijay_aroli20-Sep-06 23:50 
QuestionRe: inp( ) and outp( ) functions Pin
David Crow21-Sep-06 4:05
David Crow21-Sep-06 4:05 
QuestionConsole comminication problem Pin
susiriss20-Sep-06 18:24
susiriss20-Sep-06 18:24 
hi all,
I am trying to develop an application that interacts with a console mode application. First I created the console, ran the cmd.exe on it and redirected the Standard input so that my app can write value to the command processor. All goes well until I write to the console, in this case my text does not appear on the command prompt. When I debug, I see that WriteFile() is successful and the desired no. of bytes are written to the console handle. Can anyone identify what I am missing from the code I've used below.(echo is on by default, isn't it?). As u can see, I'm trying to display "hi" on the command prompt...!

AllocConsole();<br />
	//	Handles for the pipe ends<br />
	HANDLE hInRead, hInWrite,hInWriteDup;	//	For child's input pipe<br />
	HANDLE hOutRead,hOutWrite,hOutReadDup;	//	For child's output pipr<br />
	HANDLE hSavedOut=GetStdHandle(STD_OUTPUT_HANDLE);<br />
<br />
	SECURITY_ATTRIBUTES sa;<br />
	sa.bInheritHandle=TRUE;<br />
	sa.lpSecurityDescriptor=NULL;<br />
	sa.nLength=sizeof(SECURITY_ATTRIBUTES);<br />
<br />
	//	Creating pipe for child's input<br />
	CreatePipe(&hInRead,&hInWrite,&sa,0);<br />
	//	Creating pipe for child's output<br />
	CreatePipe(&hOutRead,&hOutWrite,&sa,0);<br />
<br />
	//Duplicate the Write handle so that it is not inheritable<br />
	DuplicateHandle(GetCurrentProcess(),hInWrite,GetCurrentProcess(),&hInWriteDup, 0,<br />
		FALSE,DUPLICATE_SAME_ACCESS);<br />
	//Duplicate the Read handle so that it is not inheritable<br />
	DuplicateHandle(GetCurrentProcess(),hOutRead,GetCurrentProcess(),&hOutReadDup, 0,<br />
		FALSE,DUPLICATE_SAME_ACCESS);<br />
	//Close the unnecessary handles<br />
	CloseHandle(hInWrite);<br />
	CloseHandle(hOutRead);<br />
	hInWrite=INVALID_HANDLE_VALUE;<br />
	hOutRead=INVALID_HANDLE_VALUE;<br />
<br />
	ZeroMemory( &si, sizeof(si) );<br />
    si.cb = sizeof(si);<br />
	si.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);<br />
	si.hStdInput = hInRead;//GetStdHandle(STD_INPUT_HANDLE); <br />
	si.hStdError = GetStdHandle(STD_ERROR_HANDLE);<br />
	si.wShowWindow = SW_SHOW;<br />
	si.dwFlags = STARTF_USESTDHANDLES| STARTF_USESHOWWINDOW;// ;<br />
<br />
    ZeroMemory( &pi, sizeof(pi) );<br />
<br />
	<br />
	if(!::CreateProcess(NULL,"cmd",<br />
		NULL,NULL,FALSE,CREATE_NEW_PROCESS_GROUP,//CREATE_NEW_PROCESS_GROUP|<br />
		NULL,<br />
		NULL,&si,&pi))<br />
		AfxMessageBox("Process Error",MB_ICONERROR,0);<br />
	//SetConsoleMode(hInRead,ENABLE_LINE_INPUT|ENABLE_ECHO_INPUT);<br />
	//SetStdHandle(STD_INPUT_HANDLE,hInRead);<br />
	DWORD num;<br />
	if(!WriteFile(hInWriteDup,"Hi",3,&num,NULL))<br />
		AfxMessageBox("Write to pipe failed",MB_ICONERROR,0);

Questionabout accessing a locked file Pin
hqfhy20-Sep-06 17:29
hqfhy20-Sep-06 17:29 
AnswerRe: about accessing a locked file Pin
Christian Graus20-Sep-06 17:48
protectorChristian Graus20-Sep-06 17:48 
GeneralRe: about accessing a locked file Pin
hqfhy20-Sep-06 17:56
hqfhy20-Sep-06 17:56 
GeneralRe: about accessing a locked file Pin
Christian Graus20-Sep-06 18:02
protectorChristian Graus20-Sep-06 18:02 
GeneralRe: about accessing a locked file Pin
hqfhy20-Sep-06 18:10
hqfhy20-Sep-06 18:10 
GeneralRe: about accessing a locked file Pin
David Crow21-Sep-06 4:07
David Crow21-Sep-06 4:07 
Questionwhat is error C2079?? Pin
dacky20-Sep-06 17:28
dacky20-Sep-06 17:28 
AnswerRe: what is error C2079?? Pin
Rinu_Raj20-Sep-06 17:33
Rinu_Raj20-Sep-06 17:33 
AnswerRe: what is error C2079?? Pin
Christian Graus20-Sep-06 17:46
protectorChristian Graus20-Sep-06 17:46 
AnswerRe: what is error C2079?? Pin
Hamid_RT21-Sep-06 8:13
Hamid_RT21-Sep-06 8:13 
QuestionHow TO : Copy Unicode Characters to Clipboard Pin
Mohammad Rastkar20-Sep-06 16:20
Mohammad Rastkar20-Sep-06 16:20 
AnswerRe: How TO : Copy Unicode Characters to Clipboard Pin
Aneesh Valeri20-Sep-06 18:09
Aneesh Valeri20-Sep-06 18:09 
GeneralRe: How TO : Copy Unicode Characters to Clipboard Pin
Mohammad Rastkar20-Sep-06 18:25
Mohammad Rastkar20-Sep-06 18:25 
AnswerRe: How TO : Copy Unicode Characters to Clipboard Pin
Rinu_Raj20-Sep-06 18:40
Rinu_Raj20-Sep-06 18:40 
AnswerRe: How TO : Copy Unicode Characters to Clipboard Pin
Mohammad Rastkar20-Sep-06 18:58
Mohammad Rastkar20-Sep-06 18:58 
AnswerRe: How TO : Copy Unicode Characters to Clipboard Pin
Rinu_Raj20-Sep-06 19:02
Rinu_Raj20-Sep-06 19:02 
GeneralRe: How TO : Copy Unicode Characters to Clipboard Pin
Naveen20-Sep-06 19:00
Naveen20-Sep-06 19:00 

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.