public MruList Add(MruList _SourceMruList) { foreach (Mru mru in _SourceMruList) { this.Add(mru); } return(this); }
public static MruList CreateRemoteHostMruListByExtList(string _Hostname, string[] _FileExtensionList) { // HKEY_USERS\S-1-5-21-854245398-1935655697-725345543-1131\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32\OpenSavePidlMRU RegistryKey Remote_HKEY_USERS = null; RegistryKey Remote_MruSubkey = null; MruList Remote_MruList = null; try { Remote_HKEY_USERS = RegistryKey.OpenRemoteBaseKey(RegistryHive.Users, _Hostname); if (Remote_HKEY_USERS != null) { string user_sid = Jrfc.ActiveDirectory.GetCurrentUserSidFromAD_AsString(); Remote_MruList = new MruList(); foreach (string ext in _FileExtensionList) { Remote_MruList.Add(_Hostname, Remote_HKEY_USERS, user_sid, ext); } Remote_MruList.AddOfficeRecent(_Hostname, _FileExtensionList); Remote_MruList.AddOfficeRecent("localhost", _FileExtensionList); //Remote_MruList.AddCommonRecent(_Hostname, Remote_HKEY_USERS, user_sid, _FileExtensionList); } } catch (System.Exception x) { Jrfc.Exception.HandleException(x); } finally { if (Remote_HKEY_USERS != null) { Remote_HKEY_USERS.Close(); } if (Remote_MruSubkey != null) { Remote_MruSubkey.Close(); } } if (Remote_MruList != null) { Remote_MruList.Sort(); return(Remote_MruList); } return(null); }
private void ApplyContextMenuItems_RemoteMruList(Object sender) { RdsApp app = (RdsApp)this.uc_RdsExplorerPanel_ListView.SelectedItem; if (app == null) { return; } MruList mru_list = app.GetRemoteMruList(); if (mru_list == null) { return; } //if(mru_list.Count() > 0) //{ // this.uc_RdsExplorerPanel_ListView.ContextMenu.Items.Insert(0, new Separator()); //} foreach (Mru mru in mru_list) { MenuItem itm = new MenuItem(); itm.Header = mru.DisplayName; //itm.Icon = new Image { Source = new BitmapImage(new Uri("Resources/pin.ico")) }; //itm.Header = CreateMruMenuItemHeader(mru); itm.Click += this.uc_RdsExplorerPanel_ContextMenu_LaunchMruItem; itm.DataContext = mru; itm.ToolTip = mru.FlybyHintText; Jrfc.Utility.AddItemToContextMenu(this.uc_RdsExplorerPanel_ListView.ContextMenu, itm, Jrfc.Utility.TYPE_OF_ADD.SkipIfExists, Utility.ADD_LOCATION.Top); } }
//HKEY_USERS\S-1-5-21-854245398-1935655697-725345543-1131\Software\Microsoft\Office\16.0\Word\User MRU\ADAL_B4A7D7A61D9D29E8FF8070E2AAA3EAFA9B2553B99B4FEE385996F488D3080F11\File MRU //public MruList LoadRemoteAppMruList(string _Hostname, string _RegistryKeyString) //{ // RegistryKey Remote_HKEY_USERS = null; // RegistryKey Remote_MruSubkey = null; // try // { // this.Clear(); // Remote_HKEY_USERS = RegistryKey.OpenRemoteBaseKey(RegistryHive.Users, _Hostname); // if (Remote_HKEY_USERS != null) // { // string user_sid = Jrfc.ActiveDirectory.GetCurrentUserSidFromAD_AsString(); // string subkey_string = user_sid + @"\Software\Microsoft\Office\16.0\Word\User MRU\ADAL_B4A7D7A61D9D29E8FF8070E2AAA3EAFA9B2553B99B4FEE385996F488D3080F11\File MRU"; // Remote_MruSubkey = Remote_HKEY_USERS.OpenSubKey(subkey_string); // string[] mru_values = Remote_MruSubkey.GetValueNames(); // } // } // catch(System.Exception x) // { // Jrfc.Exception.HandleException(x); // } // finally // { // if (Remote_HKEY_USERS != null) // Remote_HKEY_USERS.Close(); // if (Remote_MruSubkey != null) // Remote_MruSubkey.Close(); // } // return this; //} public static MruList CreateRemoteHostMruListByExt(string _Hostname, string _FileExtension) { // HKEY_USERS\S-1-5-21-854245398-1935655697-725345543-1131\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32\OpenSavePidlMRU RegistryKey Remote_HKEY_USERS = null; RegistryKey Remote_MruSubkey = null; MruList Remote_MruList = null; try { Remote_HKEY_USERS = RegistryKey.OpenRemoteBaseKey(RegistryHive.Users, _Hostname); if (Remote_HKEY_USERS != null) { string user_sid = Jrfc.ActiveDirectory.GetCurrentUserSidFromAD_AsString(); string subkey_string = user_sid + @"\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32\OpenSavePidlMRU\" + _FileExtension; Remote_MruSubkey = Remote_HKEY_USERS.OpenSubKey(subkey_string); if (Remote_MruSubkey == null) { return(null); } string[] mru_values = Remote_MruSubkey.GetValueNames(); if (mru_values != null) { if (mru_values.Count() > 0) { Remote_MruList = new MruList(); foreach (string mru_value in mru_values) { int mru_value_int; if (int.TryParse(mru_value, out mru_value_int)) // only get values with names that are int 0, 1, 2, 3, etc. Ignore "MRUListEx" { object reg_value = Remote_MruSubkey.GetValue(mru_value); if (reg_value is byte[]) { string mru_path = Jrfc.Shell.GetPathFromPIDL((byte[])reg_value); if (!string.IsNullOrWhiteSpace(mru_path)) { string mru_file = Path.GetFileName(mru_path); if (!string.IsNullOrWhiteSpace(mru_file)) { Remote_MruList.Add(new Mru(_Hostname, mru_path, mru_file)); } } } } } } } } } catch (System.Exception x) { Jrfc.Exception.HandleException(x); } finally { if (Remote_HKEY_USERS != null) { Remote_HKEY_USERS.Close(); } if (Remote_MruSubkey != null) { Remote_MruSubkey.Close(); } } if (Remote_MruList != null) { return(Remote_MruList); } return(null); }