Beispiel #1
0
        //private void fill_volume_info()
        //{
        //    IntPtr h_file = IntPtr.Zero;

        //    try
        //    {
        //        h_file = WinAPiFSwrapper.CreateFileHandle
        //            (FileName,
        //            Win32FileAccess.READ_ATTRIBUTES | Win32FileAccess.READ_EA,
        //            FileShare.ReadWrite | FileShare.Delete,
        //            FileMode.Open,
        //            is_directory ? CreateFileOptions.BACKUP_SEMANTICS : CreateFileOptions.None);

        //        FILE_FS_VOLUME_INFORMATION vol_info = ntApiFSwrapper.GetFileVolumeInfo(h_file);
        //        textBoxVolumeCreationTime.Text = string.Format
        //            (Options.GetLiteral(Options.LANG_DATE_TIME_LONG_FORMAT),
        //            vol_info.VolumeCreationDateTime.ToShortDateString(),
        //            vol_info.VolumeCreationDateTime.ToLongTimeString(),
        //            vol_info.VolumeCreationDateTime.Millisecond);
        //        textBoxVolumeLabel.Text = vol_info.VolumeLabel;
        //        textBoxVolumeSerialNumber.Text = vol_info.VolumeSerialNumber.ToString();
        //    }
        //    catch (Exception ex)
        //    {
        //        textBoxVolumeLabel.Text = ex.Message;
        //    }
        //    finally
        //    {
        //        if ((h_file.ToInt32() != WinApiFS.INVALID_HANDLE_VALUE) && (h_file != IntPtr.Zero))
        //        {
        //            WinApiFS.CloseHandle(h_file);
        //        }
        //    }
        //}

        ////private void fill_volume_attr()
        ////{
        ////    IntPtr h_file = IntPtr.Zero;


        ////    try
        ////    {
        ////        h_file = WinAPiFSwrapper.CreateFileHandle
        ////            (FileName,
        ////            Win32FileAccess.READ_ATTRIBUTES | Win32FileAccess.READ_EA | Win32FileAccess.LIST_DIRECTORY,
        ////            FileShare.ReadWrite | FileShare.Delete,
        ////            FileMode.Open,
        ////            is_directory ? CreateFileOptions.BACKUP_SEMANTICS : CreateFileOptions.None);

        ////        FILE_FS_ATTRIBUTE_INFORMATION vol_attr = ntApiFSwrapper.GetFileVolumeAttributeInfo(h_file, IntPtr.Zero, 0);
        ////        textBoxVolumeFScaps.Text = vol_attr.VolumeAttributes.ToString();
        ////        textBoxVolumeFStype.Text = vol_attr.FileSystemName;
        ////        textBoxVolumeMaxNameLen.Text = vol_attr.MaximumComponentNameLength.ToString();

        ////        if ((vol_attr.VolumeAttributes & VolumeCaps.ReadOnly) != VolumeCaps.ReadOnly)
        ////        {
        ////            try
        ////            {
        ////                FILE_FS_FULLSIZE_INFORMATION vol_fs = ntApiFSwrapper.GetFileVolumeFullsizeInfo(h_file);
        ////                textBoxVolumeAvailableUnits.Text = string.Format
        ////                    ("{0:N0}",
        ////                    vol_fs.CallerAvailableAllocationUnits);
        ////                textBoxVolumeAvailableBytes.Text = string.Format
        ////                    ("{0:N0}",
        ////                    vol_fs.UserAvailableAllocationBytes);
        ////                textBoxVolumeBytesPerSector.Text = string.Format
        ////                    ("{0:N0}",
        ////                    vol_fs.BytesPerSector);
        ////                textBoxVolumeBytesPerSector.Text = string.Format
        ////                    ("{0:N0}",
        ////                    vol_fs.BytesPerSector);
        ////                textBoxVolumeBytesPerUnit.Text = string.Format
        ////                   ("{0:N0}",
        ////                   vol_fs.BytesPerSector * vol_fs.SectorsPerAllocationUnit);
        ////            }
        ////            catch (Exception ex)
        ////            {
        ////                textBoxVolumeAvailableUnits.Text = ex.Message;
        ////            }
        ////        }

        ////        if ((vol_attr.VolumeAttributes & VolumeCaps.Quotas) == VolumeCaps.Quotas)
        ////        {
        ////            try
        ////            {
        ////                FILE_FS_CONTROL_INFORMATION vol_ctrl = ntApiFSwrapper.GetFileVolumeControlInfo(h_file);
        ////                textBoxVolumeControlFlags.Text = vol_ctrl.FileSystemControlFlags.ToString();
        ////                textBoxVolumeQuotaLimit.Text = string.Format
        ////                    ("{0:N0}",
        ////                    vol_ctrl.DefaultQuotaLimit);
        ////                textBoxVolumeQuoteThreshold.Text = string.Format
        ////                    ("{0:N0}",
        ////                    vol_ctrl.DefaultQuotaThreshold);
        ////            }
        ////            catch (Exception ex)
        ////            {
        ////                textBoxVolumeControlFlags.Text = ex.Message;
        ////            }
        ////        }
        ////    }//try
        ////    catch (Exception ex)
        ////    {
        ////        textBoxVolumeFScaps.Text = ex.Message;
        ////    }
        ////    finally
        ////    {
        ////        if ((h_file.ToInt32() != WinApiFS.INVALID_HANDLE_VALUE) && (h_file != IntPtr.Zero))
        ////        {
        ////            WinApiFS.CloseHandle(h_file);
        ////        }
        ////    }
        ////}

        //private void fill_device()
        //{
        //    IntPtr h_file = IntPtr.Zero;

        //    try
        //    {
        //        h_file = WinAPiFSwrapper.CreateFileHandle
        //            (FileName,
        //            Win32FileAccess.READ_ATTRIBUTES | Win32FileAccess.READ_EA,
        //            FileShare.ReadWrite | FileShare.Delete,
        //            FileMode.Open,
        //            is_directory ? CreateFileOptions.BACKUP_SEMANTICS : CreateFileOptions.None);

        //        FILE_FS_DEVICE_INFORMATION vol_dev = ntApiFSwrapper.GetFileVolumeDeviceInfo(h_file);
        //        textBoxVolumeDeviceCharateristics.Text = vol_dev.Characteristics.ToString();
        //        textBoxVolumeDeviceType.Text = vol_dev.DeviceType.ToString();
        //    }
        //    catch (Exception ex)
        //    {
        //        textBoxVolumeDeviceCharateristics.Text = ex.Message;
        //    }
        //    finally
        //    {
        //        if ((h_file.ToInt32() != WinApiFS.INVALID_HANDLE_VALUE) && (h_file != IntPtr.Zero))
        //        {
        //            WinApiFS.CloseHandle(h_file);
        //        }
        //    }
        //}

        private void fill_links(IO_REPARSE_TAG tag)
        {
            try
            {
                switch (tag)
                {
                case IO_REPARSE_TAG.MOUNT_POINT:
                    REPARSE_DATA_BUFFER_MOUNTPOINT mp_buf = WinAPiFSwrapper.GetMountpointInfo(FileName);
                    textBoxSoftlinks.Text = mp_buf.SubstituteName;
                    break;

                case IO_REPARSE_TAG.SYMLINK:
                    REPARSE_DATA_BUFFER_SYMLINK sl_buf = WinAPiFSwrapper.GetSymboliclinkInfo(FileName);
                    textBoxSoftlinks.Text = sl_buf.SubstituteName;
                    break;
                }
            }
            catch (Exception ex)
            {
                textBoxSoftlinks.Text = ex.Message;
            }
        }