Solved

(125 pts)  Associate a file extension - VB5

Posted on 1998-10-30
5
162 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Copy a row 12 69
Looking for VB6 code to read SQL table export it to ascii 8 47
VB6 ListBox Question 4 56
Create Files based on Cell Values in a Range in Excel 12 43
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

733 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