Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   CreateProcess help... (http://www.go4expert.com/forums/createprocess-help-t6954/)

dcer 21Oct2007 17:56

CreateProcess help...
 
hi,

want i want to do is, when u right click a shortcut > and in target, it is "PROGRAM PATH"...and u can put "PROGRAM PATH" /cmd /cmd2

how would i do that in CreateProcess() function?
Code:

CreateProcess("C\\program.exe /say hello",
 NULL,
 NULL,
 NULL,
 FALSE,
 0,
 NULL,
 NULL,
 &s,
 &p);

how would u do that?

shabbir 21Oct2007 21:14

Re: CreateProcess help...
 
Second parameter is the command line you want to pass to the exe.

dcer 22Oct2007 09:57

Re: CreateProcess help...
 
Hi,
it seem to doesn't work -_-...in order to CreateProcess, the EXE must have /load /config test2 to load the config file when the exe opens...here's CreateProcess:

Code:

CreateProcess("C:\\configeditor\\ceditor.exe",
 "/load /config defaultc",
 NULL,
 NULL,
 FALSE,
 0,
 NULL,
 NULL,
 &s,
 &p);

and i've tried:
Code:

CreateProcess("C:\\configeditor\\ceditor.exe /load /config defaultc",
 NULL,
 NULL,
 NULL,
 FALSE,
 0,
 NULL,
 NULL,
 &s,
 &p);

it doesn't seem to be doing what i want it to do..because it displays an error "Config needs to be loaded.."

shabbir 22Oct2007 10:09

Re: CreateProcess help...
 
Just check ceditor if it supports the command line you are providing because createprocess is a tried and tested over time and there is nothing you can do where the API can go wrong and all you need to be doing is pass the parameters correctly.

dcer 22Oct2007 10:46

Re: CreateProcess help...
 
Hi,

i am positive because i entered it in the TARGET(shortcut >properties) and in start >run "PROGRAM" /load /config defaultc

i write a test program in autoit...
http://www.wikifortio.com/165615/test.zip

unzip and write in start > run "PATH TO test.exe" hello...it will display a msgbox "HELLO TGHERE"
i tried doing with CreateProcess..it doesn't work

Code:

CreateProcess("C:\\test.exe",
 "hello",
 NULL,
 NULL,
 FALSE,
 0,
 NULL,
 NULL,
 &s,
 &p);


shabbir 22Oct2007 17:21

Re: CreateProcess help...
 
The code below works for me
Code:

    STARTUPINFO        si;
    PROCESS_INFORMATION pi;
       
    ZeroMemory( &si, sizeof(si) );
    si.cb = sizeof(si);
    ZeroMemory( &pi, sizeof(pi) );
       
    // Start the child process.
    BOOL bRetVal = ::CreateProcess( "Exe Path",                         
                (LPSTR)((LPCTSTR)szCommandLine),          // Command line.
                NULL,            // Process handle not inheritable.
                NULL,            // Thread handle not inheritable.
                FALSE,            // Set handle inheritance to FALSE.
                0,                // No creation flags.
                NULL,            // Use parent's environment block.
                NULL,            // Use parent's starting directory.
                &si,              // Pointer to STARTUPINFO structure.
                &pi              // Pointer to PROCESS_INFORMATION structure.
        );


dcer 22Oct2007 18:36

Re: CreateProcess help...
 
like this?

Code:

CreateProcess("C:\\test.exe",
 (LPSTR)((LPCTSTR)"hello"),
 NULL,
 NULL,
 FALSE,
 0,
 NULL,
 NULL,
 &s,
 &p);

if it is, it doesn't work. =\

shabbir 22Oct2007 19:14

Re: CreateProcess help...
 
Try running my code and if it does not work you should be exploring the areas where you API work correctly.


All times are GMT +5.5. The time now is 14:03.