Thread: a program that will call an execute but with arguments

  1. #1
    Registered User
    Join Date
    Dec 2005
    Posts
    50

    a program that will call an execute but with arguments

    is it possible in C++ that i have a program that will call on an executable of another program, but i would pass an argument to this executable from the calling program?

    i'm using borland on winxp. the only see on calling an executable is ::shellexecute. but i don't think i could pass an argument from here.

    thanks for the help..

  2. #2
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    ::ShellExecute(..)

    Code:
    HINSTANCE ShellExecute(      
        HWND hwnd,
        LPCTSTR lpOperation,
        LPCTSTR lpFile,
        LPCTSTR lpParameters,
        LPCTSTR lpDirectory,
        INT nShowCmd
    );
    See the right parameter? Use the right parameter.

  3. #3
    Registered User
    Join Date
    Dec 2005
    Posts
    50
    hmm...

    i'm not sure if i am getting this correctly...

    what if i am actually having arguments like a class? or i want to pass a class, could i use lpParameters?

    the program that will be called will have this...

    Code:
    WINAPI WinMain(HINSTANCE hCurInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
    i can't see where lpParameters could have been passed?

    sorry for such ignorance i am still on the process of learning this stuffs..

    thanks!

  4. #4
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    The application you are starting up handles initializing itself and the WinMain entrypoint, and would usually call GetCommandLine(). All you have to do is pass the executables parameters as a C-string to ShellExecute(..).

    >> what if i am actually having arguments like a class? or i want to pass a class, could i use lpParameters

    Perhaps you could serialize it in human readable format.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Client-server system with input from separate program
    By robot-ic in forum Networking/Device Communication
    Replies: 3
    Last Post: 01-16-2009, 03:30 PM
  2. Help calling function is asm
    By brietje698 in forum C++ Programming
    Replies: 24
    Last Post: 12-06-2007, 04:48 PM
  3. Need help on code to execute the program
    By hibmem10 in forum C++ Programming
    Replies: 6
    Last Post: 12-24-2005, 01:42 PM
  4. Is it possible to call a java program in C?
    By xilum68 in forum C++ Programming
    Replies: 1
    Last Post: 12-05-2003, 01:26 AM
  5. How to call another program?
    By Unreg1stered in forum C++ Programming
    Replies: 4
    Last Post: 07-21-2002, 12:03 AM