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);
		}

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);
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.