• WMI获取磁盘的GUID路径


     Windows支持一种特殊的UNC (Universal Naming Convention)路径表示法:\\?\Volume{}。例如我的D盘可以表示成\\?\Volume{7676e0e1-60fd-11de-a55b-806e6f6e6963}\。

    获取到磁盘的GUID路径

    Caption:盘符

    DeviceID:GUID路径

    例如:


                SelectQuery selectQuery = new
                   SelectQuery("Win32_Volume");
                ManagementObjectSearcher searcher =
                    
    new ManagementObjectSearcher(selectQuery);
                
    foreach (ManagementObject disk in searcher.Get())
                {
                    tmpArray.Add(disk.Properties["Caption"].Value.ToString());
                    tmpArray2.Add(disk.Properties["DeviceID"].Value.ToString());
                }

    Windows Management Instrumentation (WMI) 

    class Win32_Volume : CIM_StorageVolume
    {
    uint16 Access;
    uint16 Availability;
    uint64 BlockSize;
    string Caption;
    uint32 ConfigManagerErrorCode;
    boolean ConfigManagerUserConfig;
    string CreationClassName;
    string Description;
    boolean ErrorCleared;
    string ErrorDescription;
    string ErrorMethodology;
    datetime InstallDate;
    uint32 LastErrorCode;
    string Name;
    uint64 NumberOfBlocks;
    string PNPDeviceID;
    uint16[] PowerManagementCapabilities;
    boolean PowerManagementSupported;
    string Purpose;
    string Status;
    uint16 StatusInfo;
    string SystemCreationClassName;
    string SystemName;
    string DeviceID;
    uint64 Capacity;
    boolean Compressed;
    string DriveLetter;
    uint32 DriveType;
    string FileSystem;
    uint64 FreeSpace;
    boolean IndexingEnabled;
    boolean DirtyBitSet;
    string Label;
    uint32 MaximumFileNameLength;
    boolean Automount;
    boolean QuotasEnabled;
    boolean QuotasIncomplete;
    boolean QuotasRebuilding;
    uint32 SerialNumber;
    boolean SupportsDiskQuotas;
    boolean SupportsFileBasedCompression; 

    };

     更多详细:参考MSDN

    http://msdn.microsoft.com/en-us/library/aa394515(VS.85).aspx

    注意:Windows XP and earlier:  This class is not available.

     XP或之前的版本,不受支持 

  • 相关阅读:
    【C++】Lambda表达式
    使用velodyne16线激光雷达跑loam-velodyne
    IMU(LPMS-B2) ROS下使用教程
    【C++】关键字inline
    OpenCV中feature2D——BFMatcher和FlannBasedMatcher
    CUDA 编程
    进程(process)和线程(thread)的区别
    【C++】源自指针的报错
    【C++】如何接收函数return返回来的数组元素
    远程访问服务器tensorboard
  • 原文地址:https://www.cnblogs.com/wangbin5542/p/1752253.html
Copyright © 2020-2023  润新知