SetupDiGetClassDevs的第二个参数应该怎么设?

yux007 2003-10-16 05:08:30
SetupDiGetClassDevs(&guidHID,"DIGCF_DEVICEINTERFACE",0,DIGCF_DEVICEINTERFACE)写成这样提示无效参数,不加双引号提示:cannot convert parameter 2 from 'const int' to 'const char *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
请高手执教!
...全文
153 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
yux007 2003-10-24
  • 打赏
  • 举报
回复
是不是这样:
Cstring str="DIGCF_DEVICEINTERFACE";
char *p
p=&str;
然后参数为p就可以了?
yux007 2003-10-17
  • 打赏
  • 举报
回复
我就是想设定这个参数用来找PNP设备,DIGCF_DEVICEINTERFACE
该怎么设呢?
zoohoo 2003-10-17
  • 打赏
  • 举报
回复
废话,他要你传一个char* 你第一次传const char *,第二次传const int当然不可以了。
实在不行传一个NULL嘛

看下面的说明
HDEVINFO SetupDiGetClassDevs(
CONST LPGUID ClassGuid,
PCTSTR Enumerator,
HWND hwndParent,
DWORD Flags
);
Parameters
ClassGuid
[in] An optional pointer to a class GUID for a setup class or an interface class. If the DIGCF_DEVICEINTERFACE flag is set, ClassGuid represents an interface class; otherwise, ClassGuid represents a setup class.
If the DIGCF_ALLCLASSES flag is set, this parameter is ignored and the resulting list contains devices of all installed classes.

Enumerator
[in] An optional pointer to a string that filters the devices that are returned.
If the DIGCF_DEVICEINTERFACE flag is set, this parameter is an optional pointer to a string representing the PnP name of a particular device. This function examines this particular device only to determine whether it exposes any interfaces of the requested interface class.

If the DIGCF_DEVICEINTERFACE flag is not set, this parameter optionally specifies the name of the PnP enumerator for the devices of interest. (The names of system-supplied enumerators appear in the DDK header file Register.h.) This function examines only device instances of this enumerator. If this parameter is NULL, this function retrieves device information for all device instances on the system.

hwndParent
[in] Specifies the handle to the top-level window to be used for any user interface relating to the members of this set.

64,648

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧