UWP Get Uniqe Usb Pendrive Id



我对UWP应用程序有问题。我想获得USB Pendrive的Uniqe ID。多亏了它,我将能够区分我应该发送文件的USB pendrive。当然,我可以从知名福利德(Removabeldevices)中获得folderryitive,但是这个值不是uniqe。我认为我需要GUID,VID或PID。有什么方法可以获取所有USB存储设备和所有信息?

为您的需求,您可以使用Windows.Devices.Enumeration API获取便携式存储设备。有关更多详细信息,您可以参考 deviceenumaeration andPairing 方案2。

handlerAdded = new TypedEventHandler<DeviceWatcher, DeviceInformation>(async (watcher, deviceInfo) =>
{
    // Since we have the collection databound to a UI element, we need to update the collection on the UI thread.
    await rootPage.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () =>
    {
        ResultCollection.Add(new DeviceInformationDisplay(deviceInfo));
        rootPage.NotifyUser(
            String.Format("{0} devices found.", ResultCollection.Count),
            NotifyType.StatusMessage);
    });
});

然后,您可以从deviceInfo对象获得唯一的ID。

此问题的结果简单。您可以使用DeviceInformation ID初始化StorageDevice。然后,您可以从中获得StoragFolder。不要忘记添加引用:UWP的Windows桌面扩展。

最新更新