Computer: Programming
Project Specific File Associations   (+1)  [vote for, against]
Get the right app the first time.

In windows, clicking on a file will launch whichever application the file has been associated with based on its "extension".

I've been scratching my head trying to figure out if there is a way to write a bit of software that would over-ride these associations and make the association either folder or perhaps file specific without changing the extension.

Just pondering...
-- zigness, Jun 11 2004

File associations in Windows are just a set of entries in the registry, and you can change them. One way to approach this would be to register a small utility application for these files, instead of the target application(s). The utility application would figure out the context, and then pass along the launch information to the real application for the given context.
-- krelnik, Jun 11 2004


Interesting idea (and an interesting solution, [krelnik]).

Perhaps some day file associations will be a property of the source file, with a default that can be changed on a file-by-file basis.
-- phoenix, Jun 11 2004


Well, since Windows now gives you the choice to project or obscure extensions, how much work would be required to toggle activation based on extension visibility? Just pondering ...
-- dpsyplc, Jun 11 2004


Windows XP already supports this to some extent. If I create (or save) an html file with MS Word, then when I use the context menu to edit it, it opens in Word again, where any other html would open in my associated html editor. It also displays a different icon. Sure, this is something in the <head> of the document, but windows is displaying an ability to manage some difference in like filetypes.
-- swamilad, Jun 11 2004


You know, [krelnik]'s idea would work fine. In fact, it's similar to something I thought up while pondering this. However, I can't figure out how to control the icon that's displayed in Explorer from an external app.

I imagine that there is perhaps an API call somewhere out there that will do it. Any ideas?
-- zigness, Jun 11 2004


Create a batch file that addresses your preferences for file type associations?
In a Windows NT 4.0 command processor window (CMD.EXE), command extensions are enabled by default. To find out more about command extensions, type CMD /X /? in a CMD window. This will give you a list of system commands that are enhanced by the extensions. Type the name of an enhanced command followed by the help switch ( /? ) to see how the command is affected.
My favorite GUI trainer suggests you think ahead to the applications you wish to use, and follow up by drilling into your environmental variables to plant their association path there: Control Panel _System _Advanced _Environmental Variables
Enter Variable %path% /mybatchofappys/foofiletype.bat

I might try this on a small scale, as I have some *rogue* templates that are trying my patience.
-- dpsyplc, Jun 11 2004


Just a thought....I always use "open with". Not what you meant, of course.
-- Ling, Jun 12 2004


[zigness] - // I imagine that there is perhaps an API call somewhere out there that will do it. Any ideas //

Indeed. The Windows shell (explorer) is very hookable and extendable. If you're at least a moderately competent programmer, look up "shell namespace extension" (perhaps not exactly what you want, but you'll discover how explorer works and that'll lead to being able to do exactly what you want and then some).

[krelnik]'s solution is still the quickest+easiest approach.
-- benjamin, Jun 12 2004


[benjamin], I agree. [krelnik]'s is really the only reasonable approach I can think of. It's very close to what I had in mind to start with.

Although I've been writing code for a couple of decades, trying to manipulate explorer has never come up in what I've needed to do. I'll take a look.

[Ling], yeah, what I'm really trying to do is automate the 'open with' so that I can just double click, and it goes where it's supposed to.
-- zigness, Jun 12 2004


WinFS.
-- bristolz, Jun 12 2004


[bristolz] WinFS isn't even coming out until, what? 2010 I think, in Blackcomb, not even Longhorn.

And, for our more open members: what about any implementing of this in KDE or GNOME?
-- ironfroggy, Jun 12 2004


Isn't this a WIBNI?
-- ldischler, Jun 12 2004


No, content-addressable storage is no WIBNI. It's actively being developed.
-- bristolz, Jun 12 2004


[ldischler] must not be a programmer... but no, it's not a WIBNI
-- zigness, Jun 12 2004


Only to the extent that [zigness] would like a series of functions to behave as judged. If I may suggest that a plan is possible, to a greater or lesser degree of satisfaction, but you choose to argue for the plan giving you the greatest personal degree of satisfaction and limiting other outcomes -- you state WIBNI. This idea's just a call for consumer advice.
-- dpsyplc, Jun 12 2004


If someone says "I've been scratching my head" and "just pondering", without giving anything else even slightly sounding like a solution, that's a WIBNI, programmer or no.
-- ldischler, Jun 12 2004


I have a lot of programs listed in the "Send to ..." folder. When I right click on a file the menu pops up and I can select what program to use.

Originally I did this because with "Send to ..." MS Word magically reads files from UNIX systems without any clutter from UNIX control characters. Now I also use it to quickly load XTML files into Notepad instead of a browser.
-- kbecker, Jun 13 2004



random, halfbakery