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 / Windows Forms / WinForm General / August 2006

Tip: Looking for answers? Try searching our database.

Start an App once each PC

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Zorro - 26 Aug 2006 10:43 GMT
Hi all,

I've got a little problem with my current App.

This app should only start once on each computer.

Currently I make this in following way:

static void Main()

{

           int Count = 0;

           foreach(System.Diagnostics.Process pro in
System.Diagnostics.Process.GetProcesses())

           {

                       if(pro.ProcessName == "AppName" && Count >= 1)

                                  return;

                       else if(pro.ProcessName == "AppName ")

                                  Count = 1;

           }

           Application.Run(new Form1 ());

}

This is very easy.

But now should there two changing's.

 1.. When the Application will start again, the running app should be the
active windows
 2.. When the Application will start again with arguments, the current app
should be the active window and an Event should fire (Open Form2).

I hope somebody have an idea, how I can implement this changing's.

Thanks,

Z
Mini-Tools Timm - 29 Aug 2006 13:09 GMT
>   1.. When the Application will start again, the running app should be the
> active windows
>   2.. When the Application will start again with arguments, the current app
> should be the active window and an Event should fire (Open Form2).

If you are interested in using a third-party component to solve your
problem, we offer a .NET component that's FREE for non-commercial use.  When
another instance of your application starts, it will pass any arguments to
the original instance and then shut down.  Check it out at:

http://www.mini-tools.com/goto/comm

Signature

Timm Martin
Mini-Tools
.NET Components and Windows Software
http://www.mini-tools.com

Jim Wooley - 29 Aug 2006 13:58 GMT
> But now should there two changing's.
>
[quoted text clipped - 5 lines]
> should be the active window and an Event should fire (Open Form2).
> I hope somebody have an idea, how I can implement this changing's.

If you are using 2005, this is relatively easy. Under the project settings,
check the Enable Application Framework option and then check the Make Single
Instance Application option. To handle the additional command line arguments,
add a handler for the StartupNextInstance application event. You can grab
the command line arguments from the input parameters.

If you are using .Net 1.x, this is a bit more tricky. See my article on Single
Instance Winforms at http://devauthority.com/blogs/jwooley/archive/2005/07/28/318.aspx.

Jim Wooley
http://devauthority.com/blogs/jwooley/default.aspx

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.