King_96

winrar

Sep 21st, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. private static string GetPath(string extension)
  2.         {
  3.             try
  4.             {
  5.                 var openSubKey = Registry.ClassesRoot.OpenSubKey(extension);
  6.                 if (openSubKey != null)
  7.                 {
  8.                     var appName = (string)openSubKey.GetValue(null);
  9.                     var registryKey = Registry.ClassesRoot.OpenSubKey(appName + @"\shell\open\command");
  10.                     if (registryKey != null)
  11.                     {
  12.                         var openWith =
  13.                             (string)
  14.                             registryKey.GetValue(null);
  15.                         var appPath = openWith.Substring(1, openWith.Length - 1);
  16.                         var max = appPath.LastIndexOf(".exe", StringComparison.Ordinal);
  17.                         if (max < 1)
  18.                             max = appPath.Length;
  19.                         appPath = appPath.Substring(0, max + 4);
  20.                         return new FileInfo(appPath).FullName;
  21.                     }
  22.                 }
  23.             }
  24.             catch
  25.             {
  26.                 return "";
  27.             }
  28.             return null;
  29.         }
  30.  
  31. var unpacker = GetPath(".rar")
Add Comment
Please, Sign In to add comment