No announcement yet.

Instance Parent

  • Filter
  • Time
  • Show
Clear All
new posts

  • #21
    If wanting to detect if your program was started by commandline, or shelled from a program, or from a shortcut, or other, I am fairly sure you can not detect that from your exe.

    I tried each of those while watching "SysInternals - Process Explorer" and all copies appeared under "Explorer.exe" (All with the exception of "ShellExecute" which the program appeared under its own process
    Engineer's Motto: If it aint broke take it apart and fix it

    "If at 1st you don't succeed... call it version 1.0"

    "Half of Programming is coding"....."The other 90% is DEBUGGING"

    "Document my code????" .... "WHYYY??? do you think they call it CODE? "


    • #22
      From the deep dark shadows of DOS...

      I have not explored this topic for a number of years, so I don't know how recent versions of Windows handles it now, BUT, back in the days of DOS, a "child" program would inherit its "environment" from the caller. It was possible for the parent to set an environment variable such that the child could check it and obtain what you are calling "instance" information.

      I know that the structures no longer operate literally in the same way, but I believe I read somewhere in the MSDN that the passing of environment values had been carried over through some new mechanism...

      If this still holds true, then you could invoke the parent application from a .BAT file (yes, they still work) in which you set the value of an environment variable. Then when it calls your app, you can check that variable.

      Honestly, I don't have the time right now to track this down to either verify or reject it, so please take it as a "possible" answer that would require more research.