Open Documents With an Existing Instance of Your Application (v 2 .0)

Category:
Miscellaneous
Type:
Applications
Difficulty:
Intermediate
Author:
Arkadiy Olovyannikov

Version Compatibility: Visual Basic 6, Visual Basic 5

More information:
When you associate your application with data files, often you don't need to open a new a instance of application when a file is doubleclicked. Instead, you just want to send a command string (file name) to the previous instance. This application demonstrates a technique that allows you to do this without subclassing, using an invisible command button. The same technique can be useful for sending messages between two applications.

To see this work, run the included.exe file multiple times, with a command string passed to it.

Version 2.0 (07/23/01) uses a method superior to the one in version 1.0. In the original version, the test for the previous instance was based on the form's caption. Since the caption could change when a document is loaded, version 2.0 eliminates this dependency.


Instructions: Click the link below to download the code. Select 'Save' from the IE popup dialog. Once downloaded, open the .zip file from your local drive using WinZip or a comparable program to view the contents.

Download previnstance.zip