Reputation: 9081
I'd like to change a type of file's icon to a new one . so i add this snippet :
AF_FileAssociator assoc = new AF_FileAssociator(".akp");
string icon = assoc.DefaultIcon.IconPath;
ProgramIcon newDefIcon = new ProgramIcon(@"ake.ico");
assoc.DefaultIcon = newDefIcon;
see here
Even i put the absolute path of the icon like this for example:
ProgramIcon newDefIcon = new ProgramIcon(@"D:\ake.ico");
I get the same result.
I have the icon ake.ico
in the root of my project . When i launch the program the string icon
takes as value ake.ico
.
The problem is that the files with the extension .akp
still haven't icon .
Upvotes: 2
Views: 1848
Reputation: 9081
I found a solution : i set the icon path value equal to the path of executable application . and it's works
Upvotes: 0
Reputation: 2072
set the file association with your executable in this way...
add these lines of code in your main class
[System.Runtime.InteropServices.DllImport("shell32.dll")]
public static void SHChangeNotify(int wEventId, int uFlags, int dwItem1, int dwItem2)
{
}
then in form load event add this code
My.Computer.Registry.ClassesRoot.CreateSubKey(".glx").SetValue("", "Galaxy Database", Microsoft.Win32.RegistryValueKind.String);
My.Computer.Registry.ClassesRoot.CreateSubKey("Galaxy Database\\shell\\open\\command").SetValue("", Application.ExecutablePath + " \"%l\" ", Microsoft.Win32.RegistryValueKind.String);
const dynamic SHCNE_ASSOCCHANGED = 0x8000000;
const dynamic SHCNF_IDLIST = 0;
SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, 0, 0);
build your project and run the exe as Administartor. The icon of exe will be applied to the .apk files.
remarks: It requires administrative privileges to change some file associations. Comment the code and rebuild to disable the feature. Still the association will remain with your exe. Double clicking on *.apk file will open it with your exe.
Upvotes: 2