[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

(125 pts)  Associate a file extension - VB5

Posted on 1998-10-30
5
Medium Priority
?
165 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 100 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
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…
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…
Suggested Courses

650 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