Associate a File Extension to a Program

This tip is an addendum to the VB-2-the-Max tip CreateFileAssociation – Associate a file extension.

The following code shows the complete original tip. The addendum is in bold. Without the additional code, Windows puts a small icon inside a border (like in shortcuts).

Private Declare Sub SHChangeNotify Lib "shell32.dll" (ByVal wEventId As Long, _    ByVal uFlags As Long, ByVal dwItem1 As Long, ByVal dwItem2 As Long)Const SHCNE_ASSOCCHANGED = &H8000000Const SHCNF_IDLIST = 0' Create the new file association'' Extension is the extension to be registered (eg ".cad"' ClassName is the name of the associated class (eg "CADDoc")' Description is the textual description (eg "CAD Document"' ExeProgram is the app that manages that extension (eg "c:CadMyCad.exe")'' NOTE: requires CreateRegistryKey and SetRegistryValue functionsSub CreateFileAssociation(ByVal Extension As String, ByVal ClassName As String, _    ByVal Description As String, ByVal ExeProgram As String)    Const HKEY_CLASSES_ROOT = &H80000000        ' ensure that there is a leading dot    If Left(Extension, 1) <> "." Then        Extension = "." & Extension    End If       ' create a new registry key under HKEY_CLASSES_ROOT    CreateRegistryKey HKEY_CLASSES_ROOT, Extension    ' create a value for this key that contains the classname    SetRegistryValue HKEY_CLASSES_ROOT, Extension, "", ClassName    ' create a new key for the Class name    CreateRegistryKey HKEY_CLASSES_ROOT, ClassName & "ShellOpenCommand"    ' set its value to the command line    SetRegistryValue HKEY_CLASSES_ROOT, ClassName & "ShellOpenCommand", "", _        ExeProgram & " ""%1"""    ' addendum by Andr

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

The Latest

microsoft careers

Top Careers at Microsoft

Microsoft has gained its position as one of the top companies in the world, and Microsoft careers are flourishing. This multinational company is efficiently developing popular software and computers with other consumer electronics. It is a dream come true for so many people to acquire a high paid, high-prestige job

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a

chrome os developer mode

How to Turn on Chrome OS Developer Mode

Google’s Chrome OS is a popular operating system that is widely used on Chromebooks and other devices. While it is designed to be simple and user-friendly, there are times when users may want to access additional features and functionality. One way to do this is by turning on Chrome OS

©2023 Copyright DevX - All Rights Reserved. Registration or use of this site constitutes acceptance of our Terms of Service and Privacy Policy.

Sitemap