Solved

(125 pts)  Associate a file extension - VB5

Posted on 1998-10-30
5
158 Views
Last Modified: 2010-04-30
I'd like to programmatically associate a file extension to my program from within my program.  Is there an API or something to do it?

I'd like my program to, on the Form_Load event, check if the association is there, then if it's not, make a file association to my program.  For example, how can I programmatically make it so when someone Double-Clicks on an odd file extension (like say a .PTY file) it will start my proram.

75+ Points if you can tell me how to programmatically associate a file extension.

50+ Points if you can tell me how to test if the association is there.  (this one's not as important as I can make an .INI entry saying that the association's already there, but would be nice to know how to check)

HATCHET
0
Comment
Question by:HATCHET
5 Comments
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1442595
The keyword is registry. But I don't have any time now.
Somebody else will explain.
0
 

Expert Comment

by:Fantym
ID: 1442596
I have the registry stuff to do it and the correct keys but the information is not with me at this moment so if this question is answered before i get to it thats fine.
0
 

Accepted Solution

by:
PixelMagic earned 50 total points
ID: 1442597
You need to create at least 2 entries in the registry. Both go into the hive HKEY_CLASSES_ROOT. The first is the entry for your file extension (i.e.: .abc). Create an entry for ".abc" and set the default value to a unique program ID for your app, such as "MyApplication".

Then create an entry for "MyApplication". You need to also create a sub-key off this one called "\shell\open\command" and set the default value to the path name of your app and the way it should be called.

Here's an example of the entries:

HKEY_CLASSES_ROOT/.abc       (Default Value) = "MyApplication"
HKEY_CLASSES_ROOT/MyApplication/shell/open/command = "c:\mydir\myapp.exe"

There are other options you can do as well. This is a pretty powerful thing. Let me know if you have any other questions.
0
 
LVL 3

Author Comment

by:HATCHET
ID: 1442598
Fantym,

If you could, please do post your answer as well.  PixelMagic posted an answer that sounds right, and I'll check it to make sure it is, but I'd like to hear what you have to say on it as well.  Any info I can get will help me and I'll award points for your effort.

HATCHET
0
 
LVL 3

Author Comment

by:HATCHET
ID: 1442599
PixelMagic,

You did get the right answer, but not all of it.  Through some checking and research on it, I found you need to modify the following Keys  (using a .pty file as an example):

HKEY_CLASSES_ROOT\.pty
HKEY_CLASSES_ROOT\pty_auto_file
HKEY_CLASSES_ROOT\pty_auto_file "EditFlags"
HKEY_CLASSES_ROOT\pty_auto_file\DefaultIcon
HKEY_CLASSES_ROOT\pty_auto_file\shell
HKEY_CLASSES_ROOT\pty_auto_file\shell\open
HKEY_CLASSES_ROOT\pty_auto_file\shell\open\command


I'm awarding you 50 pts as you didn't supply an example of how to implement it, and you didn't get the second half of the question - How to check the registry if it's already there.

HATCHET
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now