服务程序在另外一台电脑上无法启动

yuga 2004-11-03 02:54:21
自己电脑上可以
可到了一台干净电脑上
CRegKey key;
lRes = key.Open(keyAppID, _T("{85D74916-CEA3-42C6-A910-ADC7A96980C0}"), KEY_READ);
就会失败
不知道是什么原因造成的?
...全文
159 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
kingzai 2004-11-03
  • 打赏
  • 举报
回复
BUG: ATL Server Registration May Fail for Non- Administrators

Q190686
SYMPTOMS
Registration or unregistration of ATL servers may fail on a machine if the logged-on user doesn't have appropriate registry access rights. In-process servers may fail and display the following message:

DllRegisterServer in projectname.dll failed. Return code was:
0x80020009.
Debug EXE servers, linked statically to the registrar code and run in the debugger, may display the following trace messages:
Failed to register, cleaning up!
The thread 0xnn has exited with code -2147352567 (0x80020009).



CAUSE
CRegKey is a class used by ATL for manipulating the registry. It's Open() and Create() methods have a REGSAM argument that specifies the security access to the particular registry key.

The REGSAM argument defaults to KEY_ALL_ACCESS. In several places in the ATL code, Open() and Create() are called without specifying the REGSAM, which means it defaults to KEY_ALL_ACCESS. KEY_ALL_ACCESS is a combination of other flags including WRITE_DAC and WRITE_OWNER.

For a non-administrator, you may not have WRITE_DAC and WRITE_OWNER permissions, which causes registration to fail.



RESOLUTION
In ATLBASE.H, change the default REGSAM for CRegKey::Create() and CRegKey::Open() to KEY_READ|KEY_WRITE:


class CRegKey
{
...
LONG Create(HKEY hKeyParent, LPCTSTR lpszKeyName, LPTSTR lpszClass =
REG_NONE, DWORD dwOptions = REG_OPTION_NON_VOLATILE,
REGSAM samDesired = KEY_READ | KEY_WRITE, // changed REGSAM
LPSECURITY_ATTRIBUTES lpSecAttr = NULL,
LPDWORD lpdwDisposition = NULL);
LONG Open(HKEY hKeyParent, LPCTSTR lpszKeyName,
REGSAM samDesired = KEY_READ | KEY_WRITE); // changed REGSAM
...
};
You need to link statically to the registrar. Building for ReleaseMinDependency will statically link to the registrar. Debug builds link dynamically to the registrar via Atl.dll. You need to add _ATL_STATIC_REGISTRY to the list of Preprocessor definitions. You can do this on the Project menu by clicking Settings. Click the C/C++ tab and select General under Category.

For additional information, please see the following article(s) in the Microsoft Knowledge Base:
Q166717 DOC: Instructions for Statically Linking to Registrar Code.



3,245

社区成员

发帖
与我相关
我的任务
社区描述
ATL,Active Template Library活动(动态)模板库,是一种微软程序库,支持利用C++语言编写ASP代码以及其它ActiveX程序。
社区管理员
  • ATL/ActiveX/COM社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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