private static OpenWithInfo KeyToOpenWithInfo(string key, OpenWithType openWithType) { string openCommand = getOpenCommand(key, false); string description = null; if (openCommand == null) { openCommand = getOpenCommand(key, true); } if (openCommand == null) { openCommand = getAppPath(key); } if (openCommand != null) { description = getExeName(openCommand); openCommand = openCommand.IndexOf("%1") != -1 ? openCommand : openCommand + " \"%1\""; } return(new OpenWithInfo() { KeyName = key, OpenCommand = openCommand, OpenWithType = openWithType, Description = description }); }
private static OpenWithInfo[] KeyListToOpenWithInfoList(string[] keys, OpenWithType openWithType) { List <OpenWithInfo> retList = new List <OpenWithInfo>(); foreach (string key in keys) { retList.Add(KeyToOpenWithInfo(key, openWithType)); } return(retList.ToArray()); }
private static string[] getOpenWithList(string ext, OpenWithType openWithType) { List <string> retList = new List <string>(); string regKeyListPath = ext + "\\" + (openWithType == OpenWithType.OpenWithList ? "OpenWithList" : "OpenWithProgids"); string[] keyList = new string[0]; using (RegistryKey rkKeyList = Registry.ClassesRoot.OpenSubKey(regKeyListPath, false)) switch (openWithType) { case OpenWithType.OpenWithList: keyList = rkKeyList != null?rkKeyList.GetSubKeyNames() : new string[0]; break; case OpenWithType.OpenWithProgIds: keyList = rkKeyList != null?rkKeyList.GetValueNames() : new string[0]; break; } return(keyList); }