Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

changing a file association back to default 1

Status
Not open for further replies.

torturedmind

Programmer
Jan 31, 2002
1,052
PH
good day to all. just wanted to know, thru code, how to change a file association back to its default associated app using code. i know that in xp we can use, say,
Code:
assoc.gif=giffile
in win98 is the problem as i dunno how to invoke winfile->files->associate... thru code. can anyone please help me on this? thanks in advanced. :peace:

kilroy [knight]
philippines

"Once a king, always a king. But being a knight is more than enough."
 

Hi Kilroy,

Haven't seen you here for a while.

In all versions of Windows, the file associations are stored in the registry, in HKEY_CLASSES_ROOT. It's easy enough to programmatically change the associations, but what you can't do is to change an association to its default.

As far as I know, the default associations aren't stored anywhere. In fact, there really isn't such a thing as default file associations -- just the associations that happened to be in force when you installed Windows. Once you've changed away from that, it's gone.

Perhaps you could explain what you are trying to achieve. Are you interested in restoring any particular association?

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
hi sir mike,

yeah. been busy with my projects.

anyways, what i'd like to do is to revert gif file association to its original app as if windows has just been freshly installed. this way, i was hoping that my report will display any gif correctly and not icons with filename. but i also need to store the current association so that after viewing/printing my report, i can associate it back to their current app.

kilroy [knight]
philippines

"Once a king, always a king. But being a knight is more than enough."
 

Kilroy,

OK, so you need a way of knowing what the original ("freshly installed") association was. It's not going to be the same in all versions of Windows (in fact, in early versions there probably isn't a default file association for GIFs).

So you will need to read the value from the Registry before you change it, then store it somewhere, then write it back when you want to restore it.

As I said before, the information is all stored under HKEY_CLASSES_ROOT. If you take a look at that in the Registry Editor, the format should be obvious.

If you're not sure how to read and write to the Registry, take a look at the classes in Registry.VCX in the Foundation Classes. This will do exactly what you want.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
sir mike,

thanks for pointing me to a place where i can start. reading/writing to the registry is really not for the faint of hearts. well... here i go...

peace! [peace]

kilroy [knight]
philippines

"Once a king, always a king. But being a knight is more than enough."
 
If you have FoxPro Advisor available, check out my article in the January 2002 issue. I show how to use the Registry class.

Tamar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top