No, I understood that. Can the program be executed several times otherwise?
By the user, for example? If not, it may be that the program itself already
provides what you need. Otherwise, you'll need to have something
identifying about the program which you can detect. "The program" means
nothing to code running in the OS. Your brain understands what it means by
that, but the code that has to make something happen has to be a lot more
specific. As I said, if the main window is named something that you can
predict, use FindWindow() (I'm sure there's been a declaration for
P/Invoking that posted here before). If the only thing that's consistent is
the name of the EXE and you're feeling pretty confident that its name is
enough to uniquely identify it, you can use ToolHelp to see what processes
are running (that, also, has been discussed here before and it's wrapped in
OpenNETCF's Smart Device Framework,
www.opennetcf.org). Ideally, the
program itself would give you something more unique, but, if you didn't
write it, you can only do so much...
Paul T.
Chuck Hecht said:
Paul
I may not of been very clear. I want to have my app at startup look to see
if program "b" is running if it is great if not then I want to be able to
start program b then proceed on with running my app.
thanks
chuck
"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
com> wrote in message news:
[email protected]...
So, what do you know about it that would allow you to detect it and,
therefore, not start it again? I presume it can be started by someone
other than you? How does the program itself stop itself from being run
multiple times by the user? Main window title? Name of the EXE? Name
of an event or mutext it creates to make sure that there is only one
instance of it running?
Paul T.