Announcement

Collapse
No announcement yet.

determine how program is started

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Michael Mattias
    replied
    If the user has to build a command line anyway......

    ..add a command-line "Quiet Mode" flag? e.g "MyApp.exe /q {rest of params}?"

    Leave a comment:


  • Paul Purvis
    replied
    Thank you all very much for your responses and showing me the way.

    I write mostly console programs and try my best to think if somebody else or myself were to be using my exe program, and how would that person want to use the program if called from a batch file file or other program. Many of these programs return a value based on results, and a lot of programs do not need to display information when managed by a batch file or called by a program, even thought it is nice to have displayed information when executing a program not from a batch or another exe program.
    I makes it much easier for anybody to interface to a program and not have any text displayed messing with an calling routine.
    I will return any helpfully information find.
    thanks
    paul purvis

    added:
    that program from sysinternals would come in helpful, but i was really thinking about a program that is running, determining its own condition of what means it was started under.
    Last edited by Paul Purvis; 29 Oct 2007, 01:55 AM.

    Leave a comment:


  • Cliff Nichols
    replied
    You could always have your program take a commandline parameter so the program trying to open it has to pass a parameter that says how it was opened.

    (although this is still open to the commandline telling the truth as to what opened it, rather than lying, and say "Shell" when it was done by "CreateProcess", but still this is a simple way to know)

    MCM mentioned:
    The PROCESSENTRY32 structure which you get with Process32First/Next includes a ThParentProcessID member. That might help.
    hmmmmm....I am quite interested in this idea...and will have to research it.

    Edwin mentioned:
    See SysInternals for processexplorer, they somehow detect the parent app.
    IMHO...do NOT attempt to replicated what they do but rather use the tool provided if it helps. (This tool has saved me MANY times, but I would recommend not attempting to replicate because to my knowledge, the hardest parts are all beyond PB compiler capabilities...in the machine driver level)
    I think MCM nearly popped a mental cork warning me about extreme concepts, and the time invested vs what you get out of it. (in this one case it was worth it to me because it was like a puzzle I could not solve, but was helldriven to not let it beat me).

    (but if you insist on trying to nail it down, then these links will help

    Pierre Bellisle, was INSTRUMENTAL in assisting me along the way, as he was doing similar and posted his code in the old source code forum that I found under NtQuerySystemInformation with %SystemHandleInformation
    and I in turn improved as I could for the code I was working on at the time at Enum Handles with NtQuerySystemInformation (improved)

    We also included discussion with all those who helped, or provided input from discussions at Process Handles? via NtDll or PsApi?

    so if you decide to take it a step further...please be kind and post beyond what we tried...but I will warn you, unless you are willing to try, try, try again...it may be a fruitless attempt.

    Good luck, and I am sure we will all be here to assist where we can.

    Leave a comment:


  • Paul Dixon
    replied
    Paul,
    it these are programs written by you then can't you just use SHELL to start the second program and pass the appropriate WndStyle or CommandString parameter to the called program?

    Paul.

    Leave a comment:


  • Michael Mattias
    replied
    The PROCESSENTRY32 structure which you get with Process32First/Next includes a ThParentProcessID member. That might help.

    If the parent process ID tracks back to CMD.EXE, it must be either a batch (command) file or a command prompt; if a program file, that's the parent process (SHELL, CreateProcess or ShellExecute[Ex]), if NULL it has no parent.

    Leave a comment:


  • Edwin Knoppert
    replied
    You might have luck using the startupinfo structure.

    GetStartupInfo()

    See www.sysinternals.com for processexplorer, they somehow detect the parent app.

    Leave a comment:


  • Paul Purvis
    started a topic determine how program is started

    determine how program is started

    is there a way to determine how a program is started.
    batch, shell,etc.
    when a program is called from another program, it would be nice to be able to run the program being called in a quiet mode(no display) or from a batch program.

    i could not find anything and never read about anything on this.
    any help please
Working...
X