0

i am having trouble incorporating this createprocess function with opening a execultable.. it is in c++ and i keep getting 2 error messages which are
C:\Program Files\Microsoft Visual Studio\MyProjects\process\process.cpp(24) : error C2143: syntax error : missing ')' before ';'
C:\Program Files\Microsoft Visual Studio\MyProjects\process\process.cpp(27) : error C2065: 'IpApplicationName' : undeclared identifier
and here is my code

bool CreateProcess(
					char IpApplicationName[1000];
					STARTUPINFO StartInfo;
					PROCESS_INFORMATION ProcessInfo;
					strcpy(IpApplicationName, "c:\\windows\\system32\\calc.exe");
					ZeroMemory(&StartInfo, sizeof(StartInfo));
					StartInfo.cb = sizeof(StartInfo);
						if (!CreateProcess(IpApplicationName, NULL, NULL, NULL, FALSE,
						HIGH_PRIORITY_CLASS | CREATE_NEW_CONSOLE, NULL, NULL, 
						&StartInfo, &ProcessInfo))
					
						 printf("===Closing  the copy File Process, continue>===\n\n");
						 CloseHandle(&ProcessInfo.hThread);
						 CloseHandle(&ProcessInfo.hProcess);
		}
2
Contributors
1
Reply
2
Views
11 Years
Discussion Span
Last Post by WolfPack
0

Nothing is wrong with your code. It compiles fine in my Visual Studio 2002 compiler.
Anyway the following change is needed.

CloseHandle(ProcessInfo.hThread);
	CloseHandle(ProcessInfo.hProcess);

Maybe the error is not in the code you posted.

This is the code I tested it in

#include <windows.h>
#include <iostream>

int main()
{
char IpApplicationName[1000];
					STARTUPINFO StartInfo;
					PROCESS_INFORMATION ProcessInfo;
					strcpy(IpApplicationName, "c:\\windows\\system32\\calc.exe");
					ZeroMemory(&StartInfo, sizeof(StartInfo));
					StartInfo.cb = sizeof(StartInfo);
						if (!CreateProcess(IpApplicationName, NULL, NULL, NULL, FALSE,
						HIGH_PRIORITY_CLASS | CREATE_NEW_CONSOLE, NULL, NULL, 
						&StartInfo, &ProcessInfo))
					
						std::cout<<("===Closing  the copy File Process, continue>===\n\n");	//WaitForSingleObject( ProcessInfo.hProcess, INFINITE );

    // Close process and thread handles. 

	CloseHandle(ProcessInfo.hThread);
	CloseHandle(ProcessInfo.hProcess);
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.