Showing posts with label VB 6. Show all posts
Showing posts with label VB 6. Show all posts

Tuesday, December 04, 2007

Detecting Whether the Application is Already Running

Recently a colegue of mine needed to know how he can determine whether his application is already running in the machine at application start.

Using this post I am going to share the solution with you all, showing how you can determine whether your application is already running in the computer. By detecting this either you can stop starting of the second instance of the application and activate the already running application for the user or you can attempt to close the earlier application and start the new one. If you does not check this then multiple applications might start and the user might complain about the application performance. Also this may cause problems occurring from locked resources.

* Visual Basic (VB)
Using VB you can easily check this by using the App object.
------------------------------------------------------------
If App.PrevInstance = True Then
MsgBox("The program '" & App.EXEName & "'is already running. Please use the running application.")
End
End If
------------------------------------------------------------

* Visual Basic .NET (VB.NET)
Using VB.NET you can do this by using Diagnostics.Process class.
------------------------------------------------------------
If Diagnostics.Process.GetProcessesByName(Diagnostics.Process.GetCurrentProcess().ProcessName).Length > 1 Then
Application.Exit()
End If
------------------------------------------------------------

Friday, September 29, 2006

Interop Forms Toolkit 1.0

Are you in Visual Basic 6 (VB 6) and would like to join the .net 2.0 fun? But is your application size stopping you?

Now with the Interop Forms Toolkit 1.0 you can run forms that you have created with .net hand in hand with vb 6 forms in a VB 6 process.
Big Picture? You don't have to convert your entire application to .net but you can partially convert your application to .net or the new forms that you plan to create can be done in .net and used in your VB6 application.

http://msdn2.microsoft.com/en-us/vbasic/aa701259.aspx

Enjoy.