简体   繁体   中英

Getting USB drive name attached to windows ce device

如何使用c#或任何或本机API获取usb驱动器的名称到我的Windows ce设备。

The folder name is localized and can change from device to device. The way I do it is to query it from the same registry location the driver used for getting the name:

using(var key = Registry.LocalMachine.OpenSubKey(
                @"\System\StorageManager\Profiles\USBHDProfile"))
{
    USBDiskFolderName = key.GetValue("Folder").ToString();
}

You may be able to start with the C# DriveInfo class:

    DriveInfo[] allDrives = DriveInfo.GetDrives();

    foreach (DriveInfo d in allDrives)
    {
        Console.WriteLine("Drive {0}", d.Name);
        Console.WriteLine("  File type: {0}", d.DriveType);
        if (d.IsReady == true)
        {
            Console.WriteLine("  Volume label: {0}", d.VolumeLabel);
            Console.WriteLine("  File system: {0}", d.DriveFormat);
            Console.WriteLine(
                "  Available space to current user:{0, 15} bytes", 
                d.AvailableFreeSpace);

            Console.WriteLine(
                "  Total available space:          {0, 15} bytes",
                d.TotalFreeSpace);

            Console.WriteLine(
                "  Total size of drive:            {0, 15} bytes ",
                d.TotalSize);
        }
    }

http://msdn.microsoft.com/en-us/library/system.io.driveinfo.aspx

or this may help:

Get List of connected USB Devices

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM