Windows Form GUI Question

Hey,

I'm making a form screen and one problem is that when I create a button, I want to link it to start another c++ program on its click.

What I'm trying to do is make a poker game and when I click my start button on the form, I want it to start running my poker.exe program.

I'm not for sure what code I should use to make this work as the tutorial didn't cover this part.

Well to start another process (program) you can use CreateProcess() which will start the program the moment it is called.

The example I'm providing is only suitable for using CreateProcessA which is made for project environments with multibyte character sets rather than the default unicode character sets (where the function would be CreateProcessW() )

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <process.h>

PROCESS_INFORMATION pi;
STARTUPINFO si;

memset( &si, 0, sizeof(STARTUPINFO) );
si.cb = sizeof(STARTUPINFO);
memset( &pi, 0, sizeof(pi));

if( CreateProcessA(
	NULL,
	"C:\Documents and Settings\admin\desktop\processnametolaunch.exe" // path to your process
	NULL,NULL,
	TRUE,
	CREATE_NEW_CONSOLE, // Launch a new process with usual entry points (ie, uses main or winmain)
	NULL,NULL,
	&si,
	&pi ) == 0 )
	; // If this function returns 0 it could not launch process

CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );

Last edited on
Topic archived. No new replies allowed.