diff options
| author | Jason <[email protected]> | 2017-07-22 23:43:39 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2017-07-22 23:43:39 +0200 |
| commit | 5afd2ec6c6d7c458c1caffc55566d4365602c122 (patch) | |
| tree | b9e2c5f7861799b7b5f209046f97052493565734 /TimeHACK.Engine/FileAssociation.cs | |
| parent | 7b12feef44adfcafd46d651adcd3e8fe11cb8523 (diff) | |
| parent | c97b5bddf841573e92c67fd2d325ca44825351f0 (diff) | |
| download | histacom2-5afd2ec6c6d7c458c1caffc55566d4365602c122.tar.gz histacom2-5afd2ec6c6d7c458c1caffc55566d4365602c122.tar.bz2 histacom2-5afd2ec6c6d7c458c1caffc55566d4365602c122.zip | |
Merge pull request #133 from Alex-TIMEHACK/master
Done a lot of work on the Windows ExplorerS
Diffstat (limited to 'TimeHACK.Engine/FileAssociation.cs')
| -rw-r--r-- | TimeHACK.Engine/FileAssociation.cs | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/TimeHACK.Engine/FileAssociation.cs b/TimeHACK.Engine/FileAssociation.cs deleted file mode 100644 index 25fe895..0000000 --- a/TimeHACK.Engine/FileAssociation.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Runtime.InteropServices; -using Microsoft.Win32; - -namespace TimeHACK.Engine -{ - public class FileAssociation - { - // Associate file extension with progID, description, icon and application - public static void Associate(string extension, - string progID, string description, string icon, string application) - { - Registry.ClassesRoot.CreateSubKey(extension).SetValue("", progID); - if (progID != null && progID.Length > 0) - using (RegistryKey key = Registry.ClassesRoot.CreateSubKey(progID)) - { - if (description != null) - key.SetValue("", description); - if (icon != null) - key.CreateSubKey("DefaultIcon").SetValue("", ToShortPathName(icon)); - if (application != null) - key.CreateSubKey(@"Shell\Open\Command").SetValue("", - ToShortPathName(application) + " \"%1\""); - } - } - - // Return true if extension already associated in registry - public static bool IsAssociated(string extension) - { - return (Registry.ClassesRoot.OpenSubKey(extension, false) != null); - } - - [DllImport("Kernel32.dll")] - private static extern uint GetShortPathName(string lpszLongPath, - [Out] StringBuilder lpszShortPath, uint cchBuffer); - - // Return short path format of a file name - private static string ToShortPathName(string longName) - { - StringBuilder s = new StringBuilder(1000); - uint iSize = (uint)s.Capacity; - uint iRet = GetShortPathName(longName, s, iSize); - return s.ToString(); - } - } -} |
