Click here to Skip to main content
15,905,148 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Ribbon Bar creates multiple menu items with same name Pin
Randor 9-Nov-09 8:13
professional Randor 9-Nov-09 8:13 
GeneralRe: Ribbon Bar creates multiple menu items with same name Pin
Dale Haessel9-Nov-09 9:35
Dale Haessel9-Nov-09 9:35 
GeneralRe: Ribbon Bar creates multiple menu items with same name Pin
Randor 9-Nov-09 10:54
professional Randor 9-Nov-09 10:54 
GeneralRe: Ribbon Bar creates multiple menu items with same name Pin
Dale Haessel9-Nov-09 12:37
Dale Haessel9-Nov-09 12:37 
GeneralRe: Ribbon Bar creates multiple menu items with same name Pin
Randor 9-Nov-09 13:15
professional Randor 9-Nov-09 13:15 
QuestionIncrease mainframe window if right side of inserted view is out of MainFrames client area [modified] Pin
Fusshoeller9-Nov-09 7:05
Fusshoeller9-Nov-09 7:05 
AnswerRe: Increase mainframe window if right side of inserted view is out of MainFrames client area Pin
«_Superman_»9-Nov-09 8:02
professional«_Superman_»9-Nov-09 8:02 
GeneralRe: Increase mainframe window if right side of inserted view is out of MainFrames client area Pin
Fusshoeller9-Nov-09 8:33
Fusshoeller9-Nov-09 8:33 
AnswerRe: Increase mainframe window if right side of inserted view is out of MainFrames client area Pin
Fusshoeller10-Nov-09 22:20
Fusshoeller10-Nov-09 22:20 
Questionhow to use createprocess to create a new console window(cmd.exe) and run commands Pin
devgo9-Nov-09 7:03
devgo9-Nov-09 7:03 
AnswerRe: how to use createprocess to create a new console window(cmd.exe) and run commands Pin
Randor 9-Nov-09 7:17
professional Randor 9-Nov-09 7:17 
GeneralRe: how to use createprocess to create a new console window(cmd.exe) and run commands Pin
devgo9-Nov-09 7:28
devgo9-Nov-09 7:28 
QuestionRe: how to use createprocess to create a new console window(cmd.exe) and run commands Pin
David Crow9-Nov-09 7:52
David Crow9-Nov-09 7:52 
GeneralRe: how to use createprocess to create a new console window(cmd.exe) and run commands Pin
Randor 9-Nov-09 7:54
professional Randor 9-Nov-09 7:54 
GeneralRe: how to use createprocess to create a new console window(cmd.exe) and run commands Pin
devgo9-Nov-09 9:18
devgo9-Nov-09 9:18 
GeneralRe: how to use createprocess to create a new console window(cmd.exe) and run commands Pin
Randor 9-Nov-09 10:19
professional Randor 9-Nov-09 10:19 
GeneralRe: how to use createprocess to create a new console window(cmd.exe) and run commands Pin
devgo9-Nov-09 10:56
devgo9-Nov-09 10:56 
GeneralRe: how to use createprocess to create a new console window(cmd.exe) and run commands Pin
devgo11-Nov-09 9:15
devgo11-Nov-09 9:15 
Hi David,

As you were aware, i am trying to execute a command in the console window created through createprocess(); now i am trying to execute the command by using Pipes as you suggested.

I am pasting the code here. i am not able to print the string on the console window created. could you please suggest what i am doing wrong.

/********************************CODE ******************************* /
void main()
{

STARTUPINFO si;
PROCESS_INFORMATION pi;
DWORD i;
HANDLE hout;
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
HWND hWnd = NULL;
TCHAR buf[128];
HANDLE g_hChildStd_IN_Rd = NULL;
HANDLE g_hChildStd_IN_Wr = NULL;
HANDLE g_hChildStd_OUT_Rd = NULL;
HANDLE g_hChildStd_OUT_Wr = NULL;
SECURITY_ATTRIBUTES saAttr;
DWORD dwRead, dwWritten;
CHAR chBuf[128];
BOOL bSuccess = FALSE;

// Set the bInheritHandle flag so pipe handles are inherited.

saAttr.nLength = sizeof(SECURITY_ATTRIBUTES);
saAttr.bInheritHandle = TRUE;
saAttr.lpSecurityDescriptor = NULL;

// Create a pipe for the child process's STDOUT.

if ( ! CreatePipe(&g_hChildStd_OUT_Rd, &g_hChildStd_OUT_Wr, &saAttr, 0) )
printf("StdoutRd CreatePipe");

// Ensure the read handle to the pipe for STDOUT is not inherited.

if ( ! SetHandleInformation(g_hChildStd_OUT_Rd, HANDLE_FLAG_INHERIT, 0) )
printf("Stdout SetHandleInformation");

// Create a pipe for the child process's STDIN.
si.hStdError = g_hChildStd_OUT_Wr;
si.hStdOutput = g_hChildStd_OUT_Wr;
si.hStdInput = g_hChildStd_OUT_Rd;
//si.dwFlags |= STARTF_USESTDHANDLES;

// Start the child process.

if( !CreateProcess("C:\\windows\\system32\\cmd.exe", // No module name (use command line).
NULL,//// Command line.
NULL, // Process handle not inheritable.
NULL, // Thread handle not inheritable.
FALSE, // Set handle inheritance to FALSE.
CREATE_NEW_CONSOLE, // No creation flags.
NULL, // Use parent's environment block.
NULL, // Use parent's starting directory.
&si, // Pointer to STARTUPINFO structure.
&pi ) // Pointer to PROCESS_INFORMATION structure.
)
{
printf( "CreateProcess failed (%d).\n", GetLastError() );
return;
}


bSuccess = WriteConsole(g_hChildStd_OUT_Rd, "dir", 3, &dwWritten, NULL);
CloseHandle(g_hChildStd_OUT_Rd);


/***********************************************************************************/
GeneralRe: how to use createprocess to create a new console window(cmd.exe) and run commands Pin
Randor 11-Nov-09 16:34
professional Randor 11-Nov-09 16:34 
QuestionIs there a way to register an activeX ocx file with relative path and not full path? Pin
eyal_balla9-Nov-09 4:31
eyal_balla9-Nov-09 4:31 
AnswerRe: Is there a way to register an activeX ocx file with relative path and not full path? Pin
Chris Losinger9-Nov-09 5:34
professionalChris Losinger9-Nov-09 5:34 
QuestionHow do I get contents of long strings in VS 2008 debugger? Pin
Interrobang9-Nov-09 4:28
Interrobang9-Nov-09 4:28 
AnswerRe: How do I get contents of long strings in VS 2008 debugger? Pin
loyal ginger9-Nov-09 4:48
loyal ginger9-Nov-09 4:48 
AnswerRe: How do I get contents of long strings in VS 2008 debugger? Pin
Chris Losinger9-Nov-09 4:50
professionalChris Losinger9-Nov-09 4:50 
QuestionSimple CToolTipCtrl trouble. Pin
Nikz29-Nov-09 4:20
Nikz29-Nov-09 4:20 

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.