Ben,
Thank you for your reply
After the GetCurrentProcess nothing comes up in the intellisense. So, I am
still in the same position.
My knowledge of C++ now after 5-6 years not using it is basically zero. I'd
prefer to create C++ apps that don't requite the framework whatsoever &
which will use the old C++ runtime files.

Signature
Newbie Coder
(It's just a name)
Ben Voigt - 20 Mar 2007 17:11 GMT
> Ben,
>
> Thank you for your reply
>
> After the GetCurrentProcess nothing comes up in the intellisense. So, I am
> still in the same position.
Intellisense often gets confused in C++ code.
You should have ended up with something like:
if
(::System::Diagnostics::Process::GetProcessesByName(::System::Diagnostics::Process::GetCurrentProcess()->ProcessName)->Length
> 1) {
...
}
> My knowledge of C++ now after 5-6 years not using it is basically zero.
> I'd
> prefer to create C++ apps that don't requite the framework whatsoever &
> which will use the old C++ runtime files.
Newbie Coder - 20 Mar 2007 17:40 GMT
Thank you Ben
Will try when I get in
Thanks again,

Signature
Newbie Coder
(It's just a name)
> > Ben,
> >
[quoted text clipped - 8 lines]
>
> if
(::System::Diagnostics::Process::GetProcessesByName(::System::Diagnostics::P
rocess::GetCurrentProcess()->ProcessName)->Length
> > 1) {
> ...
[quoted text clipped - 4 lines]
> > prefer to create C++ apps that don't requite the framework whatsoever &
> > which will use the old C++ runtime files.
Ben Voigt - 20 Mar 2007 18:18 GMT
> Ben,
>
[quoted text clipped - 7 lines]
> prefer to create C++ apps that don't requite the framework whatsoever &
> which will use the old C++ runtime files.
For a native solution (no framework dependencies), you can do the exact same
thing using EnumProcesses, but the standard way of finding an existing
instance of your application is to create a named pipe. If that fails, it's
because one already exists, so then you can open the named pipe and send a
message to the existing instance.
The problem with the "count processes" method is that it's not atomic. Two
processes could start simultaneously, count processes, see there's another
process, and both exit, even though you would want one to start. The named
pipe method deals with that race condition.