Solved

(125 pts)  Associate a file extension - VB5

Posted on 1998-10-30
5
159 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

895 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

15 Experts available now in Live!

Get 1:1 Help Now