使用 WQL 限制字符串匹配的结果
我正在为我的应用程序开发 WMI 查询。它需要为给定的 VID/PID 找到分配的虚拟 COM 端口。我的查询当前如下所示:
"SELECT DeviceID FROM Win32_SerialPort WHERE PNPDeviceID = \"USB\\VID_10C4&PID_EA60\\0001\""
根据我的研究,它应该返回 "COM8"
。但是,我得到的是空集。
WQL 中的字符串比较有效吗?我记得,SQL 允许它们,但作为一个子集,我不确定是否保留了对它们的支持。
如果有必要,我想我可以查询“SELECT DeviceID,PNPDeviceID FROM Win32_SerialPort”,然后在代码中使用字符串比较来解析结果,但如果可能的话,我更愿意限制查询中的结果。
另外,我想知道,WQL 中是否确实支持字符串比较,它们是否区分大小写,和/或有没有办法指定大小写?
谢谢。
I'm working on developing a WMI query for my application. It needs to find the assigned virtual COM port for a given VID/PID. My query currently looks like this:
"SELECT DeviceID FROM Win32_SerialPort WHERE PNPDeviceID = \"USB\\VID_10C4&PID_EA60\\0001\""
Based on my research, it should return "COM8"
. However, I'm getting an empty set.
Are string comparisons valid in WQL? As I recall, SQL allows them, but being a subset, I'm not sure if support for them was carried over.
If necessary, I suppose I can query "SELECT DeviceID,PNPDeviceID FROM Win32_SerialPort"
and then in code parse through the results using string compares, but I'd prefer to limit the results in the query, if possible.
Additionally, I was wondering, if string compares are indeed supported in WQL, are they case sensitive, and/or is there a way to specify case?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我使用了这个 (C#):
为了 WMI,我需要转义一次反斜杠,为了 C#,我需要转义一次反斜杠,所以我在查询中以四个反斜杠结束。
I used this (C#):
I needed to escape the backslashes once for WMI's sake and once again for C#'s sake, so I ended with quadruple backslashes in the query.