MegaBites-AI/Windows-powershell
0372
1// Copyright (c) Microsoft Corporation.2// Licensed under the MIT License.3 4#nullable enable5 6using System.Runtime.InteropServices;7 8internal static partial class Interop9{10 internal static unsafe partial class Windows11 {12 [LibraryImport("mpr.dll", EntryPoint = "WNetCancelConnection2W", StringMarshalling = StringMarshalling.Utf16)]13 internal static partial int WNetCancelConnection2W(string driveName, int flags, [MarshalAs(UnmanagedType.Bool)] bool force);14 15 internal static int WNetCancelConnection2(string driveName, int flags, bool force)16 {17 if (s_WNetApiNotAvailable)18 {19 return ERROR_NOT_SUPPORTED;20 }21 22 int errorCode = ERROR_NO_NETWORK;23 24 try25 {26 errorCode = WNetCancelConnection2W(driveName, flags, force: true);27 }28 catch (System.DllNotFoundException)29 {30 s_WNetApiNotAvailable = true;31 return ERROR_NOT_SUPPORTED;32 }33 34 return errorCode;35 }36 }37}38 