RegOpenUserClassesRoot失败,并显示“系统找不到指定的文件". [英] RegOpenUserClassesRoot fails with "system cannot find the specified file"
问题描述
我想在我的atl Windows服务中的HKEY_CLASSES_ROOT下访问一些子项.
msdn如下所示:
服务不应访问HKEY_CURRENT_USER或HKEY_CLASSES_ROOT,尤其是在模拟用户时.而应使用RegOpenCurrentUser或RegOpenUserClassesRoot函数.
如果您尝试从服务访问HKEY_CURRENT_USER或HKEY_CLASSES_ROOT,则它可能会失败,或者似乎可以正常工作,但是存在潜在的泄漏,可能导致加载或卸载用户配置文件时出现问题.
"
因此,我使用OpenProcessToken()获取该进程的令牌,然后调用RegOpenUserClassesRoot()尝试获取对HKEY_CLASSES_ROOT密钥的访问.但是调用失败,错误为0x00000002,提示系统找不到指定的文件".
有人知道为什么这个电话失败了吗?以及如何在我的atl服务中访问HKEY_CLASSES_ROOT?
I wanna access some subkey under HKEY_CLASSES_ROOT in my atl windows service.
the msdn says below:
"A service should not access HKEY_CURRENT_USER or HKEY_CLASSES_ROOT, especially when impersonating a user. Instead, use the RegOpenCurrentUser or RegOpenUserClassesRoot function.
If you attempt to access HKEY_CURRENT_USER or HKEY_CLASSES_ROOT from a service it may fail, or it may appear to work but there is an underlying leak that can lead to problems loading or unloading the user profile.
"
So I use OpenProcessToken() to get token of the process, then call RegOpenUserClassesRoot() to try to get access to the HKEY_CLASSES_ROOT key. But the call fails with error 0x00000002, says "system cannot find the specified file".
anyone got any idea why this call fails? and how i can access HKEY_CLASSES_ROOT in my atl service?
thanks.
推荐答案
如何使用HKLM\software\classes
作为HKCR
的笔名?
我不知道从服务访问HKCR
可能存在问题.我的服务在HKLM
How about usingHKLM\software\classes
as a pseudonym forHKCR
?
I wasn''t aware there was a potential problem accessing theHKCR
from services; I have services that are continually battering away atHKLM
这篇关于RegOpenUserClassesRoot失败,并显示“系统找不到指定的文件".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!