Giter VIP home page Giter VIP logo

Comments (5)

dbuechel avatar dbuechel commented on June 16, 2024

Can you specify how and where to set "NoDrive"? I fail to reproduce your issue.

from seb-win-refactoring.

jp-weber avatar jp-weber commented on June 16, 2024

To hide a drive it is necessary to set a registry entry "NoDrives" (also via GPO):
https://winaero.com/blog/hide-drive-windows-10-file-explorer/

So that the file explorer of the SEB can also implement this, it would be necessary to query whether NoDrives exists under the Explorer in the registry and which value is set.

from seb-win-refactoring.

jp-weber avatar jp-weber commented on June 16, 2024

@dbuechel We have fixed this issue in our fork in FileSystemDialog.xaml.cs and commented our edits with 'uni-goettingen-patch: start' and 'uni-goettingen-patch: end'

Should we create a pull, or do you want to add it directly?

// uni-goettingen-patch: start
using Microsoft.Win32;
// uni-goettingen-patch: end

namespace SafeExamBrowser.UserInterface.Desktop.Windows
{
	internal partial class FileSystemDialog : Window
	{
		// uni-goettingen-patch: begin
		private DriveInfo[] GetDrives(bool showAll = false)
		{
			var drives = DriveInfo.GetDrives();
			int noDrives = (int)Registry.GetValue("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer", "NoDrives", 0);

			if (noDrives > 0 || showAll)
			{
				return drives.Where(drive => (noDrives & (int)(Math.Pow(2, (int)(drive.RootDirectory.ToString()[0]) - 65))) == 0).ToArray();
			}

			return drives;
		}
		// uni-goettingen-patch: end

		private void InitializeFileSystem()
		{
			// uni-goettingen-patch: begin
			foreach (var drive in GetDrives())
			// uni-goettingen-patch: end
			{
				FileSystem.Items.Add(CreateItem(drive.RootDirectory));
			}

			if (FileSystem.HasItems && FileSystem.Items[0] is TreeViewItem item)
			{
				item.IsSelected = true;
			}

			if (!string.IsNullOrEmpty(initialPath))
			{
				var root = Path.GetPathRoot(initialPath);
				var path = initialPath.Replace(root, "").Split(Path.DirectorySeparatorChar);
				var segments = new List<string> { root };

				segments.AddRange(path);

				SelectInitialPath(FileSystem.Items, segments);

				if (element == FileSystemElement.File && operation == FileSystemOperation.Save)
				{
					NewElementName.Text = Path.GetFileName(initialPath);
				}
			}
		}
	}
}

from seb-win-refactoring.

dbuechel avatar dbuechel commented on June 16, 2024

Ah, great! Yes, please create a pull request.

from seb-win-refactoring.

jp-weber avatar jp-weber commented on June 16, 2024

Fixed with pull request #29

from seb-win-refactoring.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.