簡體   English   中英

獲取USB驅動器名稱附加到Windows ce設備

[英]Getting USB drive name attached to windows ce device

如何使用c#或任何或本機API獲取usb驅動器的名稱到我的Windows ce設備。

文件夾名稱已本地化,可以在設備之間進行更改。 我這樣做的方法是從驅動程序用於獲取名稱的同一注冊表位置查詢它:

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

您可以從C#DriveInfo類開始:

    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

或者這可能有所幫助:

獲取已連接USB設備的列表

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM