Open a File with its Associated Application

Category:
Files and Directories
Type:
Snippets
Difficulty:
Intermediate

Author: Guillaume Serre

Version Compatibility: Visual Basic 5

More information:
The following code will open a file with its associated application. This code uses a function in the module at http://www.freevbcode.com/ShowCode.Asp?ID=314 in order to access the registry.

This solution reads the registry to determine the default application for a given file extension. An alternative solution, using the ShellExecute API function, can be found at http://www.freevbcode.com/ShowCode.Asp?ID=12.

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

Declarations:

Code: