Allows Only One Instance of your App (Alternative Method)

Category:
Miscellaneous
Type:
Snippets
Difficulty:
Beginning
Author:
Anonymous

Version Compatibility: Visual Basic 6, Visual Basic 5

More information:
This snippet uses the FindWindow API function to prevent a second instance of your application from starting, as opposed to using app.PrevInstance, which is the standard way. To use it, add a module to your application and set Sub_Main as the startup object.

Instructions: Copy the declarations and code below and paste directly into your VB project.

Declarations:

Code: