开发者

Discover and enable/disable devices on Win8?

I'm writing a metro app for Windows 8 (C# 5) to act as a power control app allowing the user to enable and disable various devices the computer will likely have. For now, I'm just thinking bluetooth and wireless network adapter. Eventually I'll add other devices, but one step at a time.

The main aspects I'm worried about is reliably finding devices, enabling and disabling them, and querying their state (is the device already enabled?). I need to be able to do any of these on a variety of machines with a variety of different devices, including multiple NIC or Bluetooth hardware setups.

I've looked into devcon on Win7, but I'm worried about reliably discovering the devices. If I grab the wrong devices, who knows what I'll be disabling, not to mention it won't disable what I intend to disable. Also I haven't tried it on Win8 yet and it may not be a portable app, I don't want people to install it and then my app.

WMI is powerful but always a bit intimidating to wander around in without a little guidance. If that's my best bet, I would appreciate some resources.

Command line or .Net library is what I'm hoping for, but I haven't tried this kind of stuff befor开发者_高级运维e so I'm open to any other alternatives. Also, any foresight into working with other devices like cellular network cards or devices I haven't thought of yet would be great.


Much of what you want (eg Bluetooth APIs) are indeed sandboxed away from Metro apps. There are some substitutes in the Windows namespace, though whether they will meet your needs I don't know. Take a look at http://msdn.microsoft.com/en-us/library/windows/apps/hh464945 which has links to the suggested alternatives for working with devices.

Specifically the Windows.Devices.Enumeration namespace says it's about finding devices. However as I read the page it seems like it's more about discovering and less about controlling. I wouldn't be surprised to find you can't control them. But that's where I'd start digging.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜