Exemplo n.º 1
0
 public static void SetPlaces(this FileDialog fd, object[] places)
 {
     if (fd == null || places == null)
     {
         return;
     }
     if (FileDialogPlaces.m_places == null)
     {
         FileDialogPlaces.m_places = new object[places.GetLength(0)];
     }
     for (int i = 0; i < FileDialogPlaces.m_places.GetLength(0); i++)
     {
         FileDialogPlaces.m_places[i] = places[i];
     }
     if (FileDialogPlaces._fakeKey != null)
     {
         fd.ResetPlaces();
     }
     FileDialogPlaces.SetupFakeRegistryTree();
     if (fd != null)
     {
         fd.Disposed += delegate(object sender, EventArgs e)
         {
             if (FileDialogPlaces.m_places != null && fd != null)
             {
                 fd.ResetPlaces();
             }
         };
     }
 }
Exemplo n.º 2
0
 public static void ResetPlaces(this FileDialog fd)
 {
     if (FileDialogPlaces._overriddenKey != IntPtr.Zero)
     {
         FileDialogPlaces.ResetRegistry(FileDialogPlaces._overriddenKey);
         FileDialogPlaces._overriddenKey = IntPtr.Zero;
     }
     if (FileDialogPlaces._fakeKey != null)
     {
         FileDialogPlaces._fakeKey.Close();
         FileDialogPlaces._fakeKey = null;
     }
     Registry.CurrentUser.DeleteSubKeyTree(FileDialogPlaces.TempKeyName);
     FileDialogPlaces.m_places = null;
 }
Exemplo n.º 3
0
 private static void SetupFakeRegistryTree()
 {
     try
     {
         FileDialogPlaces._fakeKey       = Registry.CurrentUser.CreateSubKey(FileDialogPlaces.TempKeyName);
         FileDialogPlaces._overriddenKey = FileDialogPlaces.InitializeRegistry();
         RegistryKey reg = Registry.CurrentUser.CreateSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\ComDlg32\\PlacesBar");
         for (int i = 0; i < FileDialogPlaces.m_places.GetLength(0); i++)
         {
             if (FileDialogPlaces.m_places[i] != null)
             {
                 reg.SetValue("Place" + i.ToString(), FileDialogPlaces.m_places[i]);
             }
         }
     }
     catch
     {
     }
 }