 |
|
 |
Doesn't work with windows 7, it creates registry entries in HKEY_CLASSES_ROOT correctly but this is not where they should be placed, they must go under HKEY_CURRENT_USER\SOFTWARE\MICROSOFT\WINDOWS\CURRENTVERSION\EXPLORER\FILEEXTS\-name of your extension-
If one manually adds the appropriate entries under the above mentioned key, the association works well, and if one deletes it, its stops working, so I conclude that on my system this is the reg. key that has to be modified.
If I delete one of the other places with relevant entries, it has no effect.
Other locations that I have found (with the relevant entries) are:
A) HKEY_LOCAL_MACHINE\SOFTWARE\CLASSES\name-of-extension\OPENWITHLIST
B) HKEY_CLASSES_ROOT\-name of extension-
C) HKEY_CURRENT_USER\SOFTWARE\MICROSOFT\WINDOWS\CURRENTVERSION\EXPLORER\FILEEXTS\-name of your extension-
D) HKEY_USERS\random-user-ID\SOFTWARE\MICROSOFT\WINDOWS
ONLY by changing C) the changes have any effect!
|
|
|
|
 |
|
 |
Is '%1' the path of the opened file?
And if that is then can I get the path with this code?:
static void Main(string[] args)
{
string FilePath = args[0];
}
|
|
|
|
 |
|
|
 |
|
|
 |
|
 |
This is one of the very better articles that I have come across in a considerable period of time. A job well done.
|
|
|
|
 |
|
 |
in file ProgramAssociationInfo.cs the line 479 needs to be changed to:
registryWrapper.Write(string.Format("{0}\\{1}", this.progId, "DefaultIcon"), null, icon.ToString());
This fixes the issue I had with me not able to change the DefaultIcon
|
|
|
|
 |
|
|
 |
|
 |
It should be noted that the HKEY_CLASSES_ROOT key is actually a conglomerate view of the HKEY_LOCAL_MACHINE\Software\Classes AND the HKEY_CURRENT_USER\Software\Class, so please be careful, as sometimes one will override the other.
Also, when windows first launches a file association it creates a key under:
HKEY_CLASSES_ROOT\Software\Classes\Applications\{APPFILENAME}, where {APPFILENAME} is the filename including extension of the program associated, under this it will create a copy of the keys under the actual file association, this becomes the default when using the windows interface to create an association, which becomes a problem is the file pointed to under the Applications key no longer exists, as it stops the file from appearing in the open with list (even if you use the browse button), this key is not removed by the windows XP (maybe vista and 7 not sure) interface when going through the file types settings and restoring or deleting the association.
So if you have a problem where an association is not working be sure to check for this key and remove it.
One other place file assocations can be created is the Recommended Association list, this list can be found under:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts
And lists the default recommended programs, as per usual microsoft makes everything more complication then it needs to be, I hope this message saves someone some time, i had to find this by trial and error in the registry because it dosnt appear to be mentioned anywhere else on the net.
|
|
|
|
 |
|
 |
Dear Mr. Grant,
I hope you get out of debt fast!
This is a great project. I was looking through it and found one little oopsie that you may want to know about, although I realize that you probably haven't touched this thing in a while. In AssociationGUIForm.cs, in the extensionsListBox_SelectedIndexChanged(object, EventArgs) around line 33 of that function, you have what seems like an identical if-then statement doing the same thing, but the second time around, also setting the tag for the textbox. It looks like you wanted to replace the first if-then, but instead, replicated it and added to it. If I see more, I'll let you know, but this is a great job. Nice Registry Wrapper!
In Christ,
Aaron Laws
http://ProCure.com
|
|
|
|
 |
|
|
 |
|
 |
Hi,
I was wondering if someone could give us a hand here. I've created my own classes which sets file assiciations in the registry, much similar to this project... it seems to work perfectly fine if I register my own custom file type, but if I want to change an existing extension (like .tif for instnace) to open in my app instead of the default or current app, it won't work until I go into the associated app's settings and (un)associate the file type.
I've scanned the registry to check what it's doing, even by making use of these classes, and it sets the verbs, paths and parameters as it should, but windows still opens it in the original program (unless I first go manually unassociate)
I've been stuck on this for 5 days... my project was supposed to have been live already... it's freaking my pip. Any ideas would be awesome.
Tks,
Pip
|
|
|
|
 |
|
 |
Dear Pip,
Wow, that sucks. How did you do? I have no idea what's going on, but am curious as to how you did.
In Christ,
Aaron Laws
http://ProCure.com
|
|
|
|
 |
|
 |
You most likely have the applications key left over, to reset a file association FULLY using the registry delete these keys (NOTE: the windows interface dosnt even reset some of these):
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.{EXT}
HKEY_LOCAL_MACHINE\Software\Classes\.{EXT}]
HKEY_LOCAL_MACHINE\Software\Classes\Applications\{YOURAPPNAME}
HKEY_LOCAL_MACHINE\Software\Classes\{EXT}_auto_file
HKEY_CURRENT_USER\Software\Classes\.{EXT}]
HKEY_CURRENT_USER\Software\Classes\Applications\{YOURAPPNAME}
HKEY_CURRENT_USER\Software\Classes\{EXT}_auto_file]
Replacing
{EXT} with your file extension
{YOURAPPNAME} with the FILENAME.EXT of your application
Doing this will not only ensure your newly created assocation will work, but it will also remove any crap that windows has added from the open with interface creating its associations ({EXT}_auto_file and the like).
|
|
|
|
 |
|
 |
I am developing open - source free project under GNU public license. I want to use your code as is, without modifying, just add your project to my solution. Can I use your code ?
I see somewhere in a code, that it can't be used in a GNU projects.
|
|
|
|
 |
|
 |
I am not able to associate your files with my project kindly let me knw urgently.....
|
|
|
|
 |
|
 |
Nice works, but I don't know how to step by step use it in my application. All I want is that after install my application, user can open a file by double click into it, of course this file with my extension. Can you describe more details?
Michael Egan
|
|
|
|
 |
|
 |
Hi,
It does not work under VISTA, I don t know why !
Do you have an idea ?
|
|
|
|
 |
|
 |
A little tweak for proper file handling if filename is with spaces like "C:\Documents and settings\...", shoud be:
//Path and arguments to use
@"C:\SomePath\MyApp.exe ""%1"""
|
|
|
|
 |
|
 |
Brendan,
How to get the icon from path string of ProgramAssociationInfo.DefaultIcon ?
I'm writing a explorer type program, and will need to display icon for each file type.
You done a great job, , thanks much.
Anh Tuan
|
|
|
|
 |
|
 |
mmhh... You can get the path to the icon and load it into your ListView (Or any other control) using standart C# Commands!
FileAssociationInfo hFAInfo = new FileAssociationInfo(".test");
if (hFAInfo.Exists)
{
ProgramAssociationInfo hPAInfo = new ProgramAssociationInfo(hFAInfo.ProgID);
string sIconPath = hPAInfo.DefaultIcon.Path.ToString();
}
Greetings!
Bier
|
|
|
|
 |
|
 |
Hey!
Nice Code... pretty easy to use! But I found an Bug... If I set an DefaultIcon for a ProgrammAssociation the libary creates an DefaultIcon string value to my icon. At least Windows (XP... dunno how it is in other Win Versions) uses a key with an string (Standart) including the Icon. Your GUI even doesn't show my icon!
To make this a little bit more understood I try to show this on an "example":
Your's libary creates something like this:
-[KEY]Prog.ID
--(Standard)
--DefaultIcon
--[KEY]shell
...
But Windows wants something like this:
-[KEY]Prog.ID
--(Standard)
--[KEY]DefaultIcon
---(Standard) //Path to the Icon
--[KEY]shell
...
I try to fix this, but it would be cool if you could try this too!
Greetings and thanks for the nice code! =)
//EDIT:
protected void SetDefaultIcon(ProgramIcon icon)
{
if (!this.Exists)
throw new Exception("Extension does not exist");
if (icon != ProgramIcon.None)
{
RegistryKey root = Registry.ClassesRoot;
RegistryKey key = root.OpenSubKey(this.progId, true);
RegistryKey tmpkey = key.OpenSubKey("DefaultIcon", true);
if (tmpkey != null)
{
key.DeleteSubKeyTree("shell");
}
tmpkey = key.CreateSubKey("DefaultIcon");
registryWrapper.Write(this.progId + "\\DefaultIcon", "", icon.ToString());
ShellNotification.NotifyOfChange();
}
}
Works for me
Greetz!
-- modified at 5:43 Sunday 2nd December, 2007
Bier
|
|
|
|
 |
|
 |
This code is incorrect. Correct version:
protected void SetDefaultIcon(ProgramIcon icon)
{
if (!this.Exists)
throw new Exception("Extension does not exist");
if (icon != ProgramIcon.None)
{
RegistryKey root = Registry.ClassesRoot;
RegistryKey key = root.OpenSubKey(this.progId, true);
RegistryKey tmpkey = key.OpenSubKey("DefaultIcon", true);
if (tmpkey == null)
{
tmpkey = key.CreateSubKey("DefaultIcon");
}
registryWrapper.Write(this.progId + "\\DefaultIcon", "", icon.ToString());
ShellNotification.NotifyOfChange();
}
}
|
|
|
|
 |
|
 |
I tried compiling your code but I'm facing an exception "Access to registry key HKEY_...ROOT\.ewf is denied"
I'm running Vista Busines.
"Do u think that my being stronger or faster has anything to do with my muscles in a place like this".
|
|
|
|
 |
|
 |
Are you receiving that exception during compilation or execution?
Chances are you are running into that exception because your user account doesn't have permission to write to or create that registry key.
Currently my code only writes to HKEY_CLASSES_ROOT, perhaps in future it will support writing to HKEY_CURRENT_USER\Software\Classes as well so that an app can register user specific file associations.
Ordinarily when writing to an admin only portion of the registry, Vista's Registry Virtualization would kick in... however it doesn't apply in this case as we are writing to HKEY_CLASSES_ROOT and not HKEY_LOCAL_MACHINE\Software.
For now, try running the application as Administrator when setting/editing system wide associations (which is truly an admin operation).
|
|
|
|
 |
|
 |
In vista, the file associations information is written in HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts instead of HKEY_CLASSES_ROOT.
It will read HKEY_CLASSES_ROOT unless there is no infomation existed in HKEY_CURRENT_USER.
And the key in HKEY_CURRENT_USER will be created when user opens file associations in the contro panel.
|
|
|
|
 |