动态加载驱动函数ActivateDeviceEx() 什么情况下返回0?

rickys2080 2012-10-25 05:59:52
从网上一些资料看,ActivateDeviceEx()如果执行失败,应该返回句柄INVALID_HANDLE_VALUE,但是我在用的时候发现,很多时候返回0也是驱动加载失败的情况,比如:注册表值设置错误。这时驱动加载是失败的,不可用。
但有时候返回0,是因为驱动重复加载,这时驱动是可用的。
请问,还有哪些情况此函数返回0?
返回0的具体意义是什么?
...全文
186 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
rickys2080 2012-10-28
  • 打赏
  • 举报
回复
GetLastError
OK,我试试
gooogleman 2012-10-27
  • 打赏
  • 举报
回复
if successful. If the function is not successful, it returns INVALID_HANDLE_VALUE. To obtain extended error information, call GetLastError.


---------------------GetLastError
rickys2080 2012-10-26
  • 打赏
  • 举报
回复
1楼的资料我之前看过,没说明返回0是怎么回事,0不是一个有效的HANDLE,但具体是什么意思呢?
rickys2080 2012-10-26
  • 打赏
  • 举报
回复
谢谢楼上。
还有高人指点吗?
一介布衣萧萧 2012-10-26
  • 打赏
  • 举报
回复
This function loads a driver and adds its registry values to the Active key in the registry.

HANDLE ActivateDeviceEx(
LPCWSTR lpszDevKey,
LPCVOID lpRegEnts,
DWORD cRegEnts,
LPVOID lpvParam
);
Parameters

lpszDevKey
[in] Pointer to a string containing the registry path of the device driver's registry key. This key contains the driver's DLL name, prefix, and other data. For information about the subkeys of the HKEY_LOCAL_MACHINE\Drivers\Active registry key, see Device Manager Registry Keys.
lpRegEnts
[in] Pointer to an array of REGINI structures, each of which defines a registry value to add to the device's Active registry key before its driver is loaded. Set to NULL unless it is for a bus driver.
cRegEnts
[in] Count of the number of REGINI structures to which lpRegEnts points. This affects a generalization of the ActivateDevice function.
lpvParam
[in] Opaque pointer to a driver-specific data structure. You can use it to pass parameters to the loaded driver without having to write them through the registry. lpvParam is passed to the XXX_Init (Device Manager) function as a second parameter. lpvParam can be used by bus drivers to pass bus-specific information, entry points, or both to loaded drivers. Using this parameter prevents clients of that bus from becoming bus-agnostic. This is acceptable for some busses, especially those whose drivers cannot become bus-agnostic.
Return Values

Returns a handle that you can use later as the parameter to the DeactivateDevice function, if successful. If the function is not successful, it returns INVALID_HANDLE_VALUE. To obtain extended error information, call GetLastError.

19,502

社区成员

发帖
与我相关
我的任务
社区描述
硬件/嵌入开发 嵌入开发(WinCE)
社区管理员
  • 嵌入开发(WinCE)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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