Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / March 2007

Tip: Looking for answers? Try searching our database.

Previous Existance (Managed C++.NET 2003)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Newbie Coder - 19 Mar 2007 21:34 GMT
Can anyone convert this to managed C++.NET 2003?

Private Function PrevInstance() As Boolean
   If
UBound(System.Diagnostics.Process.GetProcessesByName(System.Diagnostics.Proc
ess.GetCurrentProcess.ProcessName)) > 0 Then
       Return True
   Else
       Return False
   End If
End Function

When I try to convert it the 'ProcessName' doesn't work

... to (System::Diagnostics::Process::GetCurrentProcess

That is when I cannot use: GetCurrentProcess::ProcessName)) >0

Any suggestions would be grateful

Thanks in advance,

Signature

Newbie Coder
(It's just a name)

Ben Voigt - 20 Mar 2007 14:07 GMT
> Can anyone convert this to managed C++.NET 2003?
>
[quoted text clipped - 11 lines]
>
> ... to (System::Diagnostics::Process::GetCurrentProcess

GetCurrentProcess sounds like a function, which requires trailing
parentheses.

I also have to remind you that converting code to Managed Extensions for C++
(VC2003) is about the worst possible thing to do.  It's unsupported, buggy,
and won't be fixed, ever.  Please use C++/CLI instead, you'll save yourself
a lot of pain.

> That is when I cannot use: GetCurrentProcess::ProcessName)) >0
>
> Any suggestions would be grateful
>
> Thanks in advance,
Newbie Coder - 20 Mar 2007 15:32 GMT
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.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.