问题描述
我想要维护一个可移动存储文件夹的StorageFolder数组。在设备添加/更新/删除时执行某些操作。
I want maintain a StorageFolder array of removable storage folders. And do something when device add/update/remove.
首先,我从KnownFolders :: RemovableDevices获取所有StorageFolder,并使用 DeviceInformation :: CreateWatcher来监听add / update / remove事件。
First, I get all StorageFolder from KnownFolders::RemovableDevices, and use DeviceInformation::CreateWatcher to listen add/update/remove event.
如果设备是便携式的,我可以使用Windows :: Devices :: Portable :: StorageDevice :: FromId(device-> Id)来获取StorageFolder,因此 已知哪个StorageFolder已更改,但如果设备是物理/虚拟CDROM,我找不到在DeviceInformation和StorageFolder之间映射
的方法。
If device is portable I can use Windows::Devices::Portable::StorageDevice::FromId(device->Id) to get StorageFolder and hence known which StorageFolder changed, but if device is physical/virtual CDROM, I can't find a way to mapping between DeviceInformation and StorageFolder.
My Watcher AQS:
My Watcher AQS:
我还尝试为Watcher添加additionalProperties和 folder-> Properties-> RetrievePropertiesAsync,但无法找到有用的映射信息:
I also try add additionalProperties for Watcher and folder->Properties->RetrievePropertiesAsync, but can't find useful information for mapping:
所有windows属性来自 https://docs.microsoft.com/en-us/windows/desktop/properties/props除了一些属性将导致崩溃。
all windows property from https://docs.microsoft.com/en-us/windows/desktop/properties/props except some property will cause crash.
接收设备观察程序事件时,有没有办法准确确定哪个CDROM StorageFolder发生了变化?
Is any way to exactly determine which CDROM StorageFolder changed when I receive device watcher event?
谢谢。
推荐答案
好吧,似乎没有内置的API,可以知道CD-ROM的文件夹更改。您可能仍然可以使用其他一些方法来使用Win32 API来检测它。
Well, it seems there is no built-in APIs that could know the folders changes of a CD-ROM. You might still use some other ways maybe Win32 APIs to detect this.
祝你好运,
Roy
这篇关于[UWP]如何在StorageFolder和DeviceInformation之间获取CDROM设备的映射?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!