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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CreateProcess

Status
Not open for further replies.

d0s

Programmer
Apr 15, 2004
48
US
does anyone know how i can add input from a textbox to the 2nd parameter of CreateProcess(the command line)...right now i have the executable name in the first parameter, then i have " +connect ", in the 2nd ive tried doin this but got an error:
Code:
" +connect " && textBox1->Text,
and i get the error:
Form1.h(196): error C2664: 'CreateProcessA' : cannot convert parameter 2 from 'bool' to 'LPSTR'

anyone got any ideas on how i can do this?
 
Well you could post more code than that.
We need to see the context in which you're using it (as well as your question) before we can suggest a way to solve it.

Perhaps using strcat to create a new string, then passing that new string to CreateProcess is the way to go.


--
 
aight didn't think you needed the whole thing but here it is..
Code:
STARTUPINFO si;
PROCESS_INFORMATION pi;

ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );


if (!CreateProcess( "app.exe", 
" +connect " && textBox1->Text, 
NULL, 
NULL, 
FALSE,
0, 
NULL,
"C:\",
&si, 
&pi ))

WaitForSingleObject( pi.hProcess, INFINITE );

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

i tried usin strcat like so:
Code:
char str[40];
strcpy (str," +connect ");
strcat (str,textBox1->Text);
STARTUPINFO si;
PROCESS_INFORMATION pi;

ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );


if (!CreateProcess( "app.exe", 
str, 
NULL, 
NULL, 
FALSE,
0, 
NULL,
"C:\",
&si, 
&pi ))

WaitForSingleObject( pi.hProcess, INFINITE );

CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
but came with the error:
Form1.h(180): error C2664: 'strcat' : cannot convert parameter 2 from 'System::String __gc *' to 'const char *'

any ideas? Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top