How to combine console based application with dialog based app visual studio c++

I have an mfc application and it is a simple dialog box that takes in user input and stores that information as separate variables. I also have a separate console based application, and once the user presses "okay" on the dialog box, the console based application should pop up, with information on it that depends on the user's input from the dialog box (reads from the variables). I have been suggested to use createprocess() to launch the console based application, but when I try to use it and press "okay" the following error occurs:

Unhandled exception at 0x7518b77b in RLGCDialog.exe: 0xC0000005: Access violation writing location 0x01177bd6.

I have attached the code where I use the function.

My next question is once I fix this, how can I send the data from the GUI to the console based app? Would combining the projects be easier/how would I go about doing that? Thanks in advanced.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
void CRLGCDlg::OnClickedOk()
{


	   STARTUPINFO si;
	   PROCESS_INFORMATION pi;
	   	
	   BOOL bStatus;

	   memset( &si, 0, sizeof(STARTUPINFO) );             //  Initialize structures
	   memset( &pi, 0, sizeof(PROCESS_INFORMATION) );

	   si.cb = sizeof(STARTUPINFO);
	   si.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;
	

	// TODO: Add extra validation here
	
	bStatus = CreateProcess(NULL, TEXT("C:\\Users\\SICAD\\Desktop\\RLGC\\RLGC_JSA\\Debug\\RLGC.exe"), NULL, NULL, TRUE, CREATE_NEW_CONSOLE, NULL, NULL, &si, &pi );


	CDialogEx::OnOK();

}
	
Last edited on
I think the problem is with the arguments check the following link http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx



You can create consoles in a gui app and windows in a console app. Check out the console functions...

http://msdn.microsoft.com/en-us/library/windows/desktop/ms682073%28v=vs.85%29.aspx
Topic archived. No new replies allowed.