locked
Getting commandline of parent process RRS feed

  • Question

  • I am using Visual Studio 2005

    The problem scenarios is:

    binary.exe launches "parent.exe -option optionValue" commandline

    The parent.exe launches a child.exe executible. In the child.exe process I want to know the arguments passed to parent.exe process, i.e.  option and optionValue, with which parent.exe was originally launched.

     

    I am trying to do it as follows in child.exe:

     

    GetCurrentProcessId()

    CreateToolhelp32Snapshot()

    get the parent process ID of child.exe process

    I get PROCESSENTRY32 for parent process ID.

     

    However PROCESSENTRY32.szExeFile gives only name of the binary and not the full commandline.

    Also QueryFullProcessImageName() gives only full path of the parent.exe.

    Is there a way to fetch the commandline options passed to parent.exe in launching it?

     

    Wednesday, February 27, 2008 11:36 AM