From 9cbbea94a67402f6ff9f3a2addbf82da50430cb8 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Sun, 21 Apr 2019 20:32:18 +0100 Subject: [PATCH] Be able to enumerate devices under win32 when running under .NET Core. --- DiscImageChef.Devices/DiscImageChef.Devices.csproj | 1 + DiscImageChef.Devices/Windows/ListDevices.cs | 13 +++++-------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/DiscImageChef.Devices/DiscImageChef.Devices.csproj b/DiscImageChef.Devices/DiscImageChef.Devices.csproj index cddbbd8d4..4b053a794 100644 --- a/DiscImageChef.Devices/DiscImageChef.Devices.csproj +++ b/DiscImageChef.Devices/DiscImageChef.Devices.csproj @@ -100,6 +100,7 @@ + diff --git a/DiscImageChef.Devices/Windows/ListDevices.cs b/DiscImageChef.Devices/Windows/ListDevices.cs index aeb3a457f..3179ab977 100644 --- a/DiscImageChef.Devices/Windows/ListDevices.cs +++ b/DiscImageChef.Devices/Windows/ListDevices.cs @@ -1,4 +1,4 @@ -// /*************************************************************************** +// /*************************************************************************** // The Disc Image Chef // ---------------------------------------------------------------------------- // @@ -33,14 +33,11 @@ using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; +using System.Linq; +using System.Management; using System.Runtime.InteropServices; using System.Text; using Microsoft.Win32.SafeHandles; -#if !NETSTANDARD2_0 -using System.Linq; -using System.Management; - -#endif namespace DiscImageChef.Devices.Windows { @@ -72,7 +69,6 @@ namespace DiscImageChef.Devices.Windows // TODO: Any way to fill this in .NET Standard ??? List deviceIDs = new List(); - #if !NETSTANDARD2_0 try { ManagementObjectSearcher mgmtObjSearcher = @@ -99,12 +95,13 @@ namespace DiscImageChef.Devices.Windows return null; #endif } - #endif List devList = new List(); foreach(string devId in deviceIDs) { + if(devId is null) continue; + string physId = devId; // TODO: This can be done better if(devId.Length == 2 && devId[1] == ':') physId = "\\\\?\\" + devId;