how can a C program run another program in same directory?

kelvinlaw
kelvinlaw used Ask the Experts™
on
how can a c program run another program in same directory?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
using system function from the process.h
either

system("command");

or CreateProcess api call, this gives better control

Author

Commented:
would u pls teach me how to createprocess api call?
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

well include windows.h

then


void pm_win_exec(char *cmd)
{
     STARTUPINFO si;
    PROCESS_INFORMATION pi;

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

    CreateProcess(NULL,cmd,NULL,NULL,FALSE,0,NULL,NULL,&si,&pi);
   
    WaitForSingleObject(pi.hProcess, INFINITE );
   
    CloseHandle(pi.hProcess);
    CloseHandle(pi.hThread);
}

Author

Commented:
would u pls teach me how to createprocess api call?

Commented:
u can use
execve also
or use WinExec
Top Expert 2006

Commented:
No comment has been added lately and this question is therefore classified abandoned.

If asker wishes to close the question, then refer to
http://www.experts-exchange.com/help/closing.jsp

Otherwise, I will leave a recommendation in the Cleanup topic area that this question is:
PAQed with A grade to makerp

Please leave any comments here within the next seven days. It is assumed that any participant not responding to this request is no longer interested in its final disposition.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Sunny
EE Cleanup Volunteer

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial