1 private String GetFileTypeString(String theExtension)
2 { 3 // HKEY_CLASSES_ROOT //
4 RegistryKey root = Registry.ClassesRoot;
5 // something like '.csproj'
6 RegistryKey openValue = root.OpenSubKey(theExtension);
7 try
8 { 9 if (openValue != null)
10 { 11 // This will get the name of a key -
12 //something like 'VisualStudio.csproj.8.0'
13 String val = openValue.GetValue("").ToString(); 14 // So we go there to get the value //
15 RegistryKey typeVal = root.OpenSubKey(val);
16 // something like 'Visual C# Project file'
17 m_FileType = typeVal.GetValue("").ToString(); 18 return typeVal.GetValue("").ToString(); 19
20 }
21 else
22 { 23 // Sometimes its unrecognized //
24 m_FileType = theExtension + " File";
25 return theExtension + " File";
26 }
27 }
28 //Sometimes the default key value is Null...no big deal
29 catch (Exception ex)
30 { 31 m_FileType = theExtension + " File";
32 return theExtension + " File";
33 }
34 }
0 comments:
Post a Comment