Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

createprocess doesnt work 1

Status
Not open for further replies.

SiaMeX

Programmer
Jul 31, 2003
28
US
how can i create process on C/C++ using win apis??? i used CreateProcess but it didnt worked... is there any alternative function when im using c/c++ importing win apis?thanks....
 
CreateProcess() sure does work ok.

It takes a lot of parameters, and you may have a problem here.
What error code does it return (GetLastError()) ?


/JOlesen
 
Post the code that creates the process, probably an error there....

Greetings,
Rick
 
this is the code:
CreateProcess(NewProcess, NewProcess, NULL, NULL, NULL, 0x10, NULL, NULL, p1, p2);
the last 2 params are pointers to defined struct.
I also used this func w/ the same params in assembly and it worked perfectly, but wen in use it in C/C++, it generates an error: "failed to initialize application". the NewProcess actually runs and terminated imidiately after displaying such msg.
thanks...
 
If both the application name and the command line arguments are non-NULL, the null-terminated string pointed to by the application name argument specifies the module to execute, and the null-terminated string pointed to by the command line argument specifies the command line.

You have both these arguments specified and identical - are you sure this is correct for your call ?

That being correct I would have a closer look at your flags parameter.

As an example :
void foo()
{
STARTUPINFO si;
PROCESS_INFORMATION pi;

memset (&pi, 0, sizeof(pi));
memset (&si, 0, sizeof(si));

si.cb = sizeof(si);
si.dwFlags |=STARTF_USESHOWWINDOW;
si.wShowWindow|=SW_SHOWNORMAL;


if ( !CreateProcess (
NULL,
"C:\\pandora\\loves\\me\\sooogood.exe",
NULL,
NULL,
false,
CREATE_NEW_CONSOLE,
NULL,
NULL,
&si,
&pi))
{
MessageBox(0, "Whoops'a Daisy.", "Error", MB_ICONSTOP);
}
{
CloseHandle(&pi.hProcess);
CloseHandle(&pi.hThread);
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top