Esempio n. 1
0
        private static bool PreventVolumeRemoval(IntPtr handle, bool prevent)
        {
            byte[] buf = new byte[1];
            uint   retVal;

            buf[0] = prevent ? (byte)1 : (byte)0;
            return(OSDelegate.DeviceIoControl(handle, IOCTL_STORAGE_MEDIA_REMOVAL, buf, 1, IntPtr.Zero, 0, out retVal, IntPtr.Zero));
        }
Esempio n. 2
0
        private static bool LockVolume(IntPtr handle)
        {
            uint byteReturned;

            return(OSDelegate.DeviceIoControl(handle, FSCTL_LOCK_VOLUME, IntPtr.Zero, 0, IntPtr.Zero, 0, out byteReturned, IntPtr.Zero));
        }
Esempio n. 3
0
        private static bool DismountVolume(IntPtr handle)
        {
            uint byteReturned;

            return(OSDelegate.DeviceIoControl(handle, FSCTL_DISMOUNT_VOLUME, IntPtr.Zero, 0, IntPtr.Zero, 0, out byteReturned, IntPtr.Zero));
        }
Esempio n. 4
0
        private static bool EjectVolume(IntPtr handle)
        {
            uint byteReturned;

            return(OSDelegate.DeviceIoControl(handle, IOCTL_STORAGE_EJECT_MEDIA, IntPtr.Zero, 0, IntPtr.Zero, 0, out byteReturned, IntPtr.Zero));
        }