/// <summary> /// Define a new DOS device. /// </summary> /// <param name="flags">The dos device flags.</param> /// <param name="device_name">The device name to define.</param> /// <param name="target_path">The target path.</param> public static void DefineDosDevice(DefineDosDeviceFlags flags, string device_name, string target_path) { if (!Win32NativeMethods.DefineDosDevice(flags, device_name, target_path)) { throw new SafeWin32Exception(); } }
/// <summary> /// Overridden ProcessRecord. /// </summary> protected override void ProcessRecord() { DefineDosDeviceFlags flags = DefineDosDeviceFlags.None; if (NoBroadcastSystem) { flags |= DefineDosDeviceFlags.NoBroadcastSystem; } if (RawTargetPath) { flags |= DefineDosDeviceFlags.RawTargetPath; } string device_path = ConvertDevicePath(DeviceName); Win32Utils.DefineDosDevice(flags, device_path, TargetPath); }
/// <summary> /// Overridden ProcessRecord. /// </summary> protected override void ProcessRecord() { DefineDosDeviceFlags flags = DefineDosDeviceFlags.RemoveDefinition; if (NoBroadcastSystem) { flags |= DefineDosDeviceFlags.NoBroadcastSystem; } if (RawTargetPath) { flags |= DefineDosDeviceFlags.RawTargetPath; } if (!string.IsNullOrEmpty(ExactMatchTargetPath)) { flags |= DefineDosDeviceFlags.ExactMatchOnRemove; } string device_path = AddDosDeviceCmdlet.ConvertDevicePath(DeviceName); Win32Utils.DefineDosDevice(flags, device_path, string.IsNullOrEmpty(ExactMatchTargetPath) ? null : ExactMatchTargetPath); }
internal static extern bool DefineDosDevice(DefineDosDeviceFlags dwFlags, string lpDeviceName, string lpTargetPath);
private static extern bool DefineDosDevice( [In, MarshalAs(UnmanagedType.U4)] DefineDosDeviceFlags dwFlags, [In] string lpDeviceName, [In] string lpTargetPath );