上网搜索了半天,最终还是在微软的官方网站上找到了一点儿蛛丝马迹:“ When you register an ATL server, you might get error
0x80040154 (Class not registered). For DLLs, REGSVR32.exe returns this error.
For EXEs, the call to _Module::RegisterServer(CComModule::RegisterServer) in
_tWinMain() returns this error.”,接着往下看 “Install ATL70.dll (or ATL.dll for earlier versions of
Visual Studio) in the Windows\System or Winnt\System32 directory. You do not
have to register ATL70.dll, however, you must register ATL.dll by using
Regsvr32.exe. There are UNICODE and ANSI versions of ATL70.dll and ATL.dll.
Install the appropriate version on the target operating system (that is,
UNICODE for Microsoft Windows NT, and ANSI for Microsoft Windows 95 or
Microsoft Windows 98).”
哦,原来是system32下面的atl.dll没有注册,打开C:\windows\system32\找到atl.dll后使用regsvr32注册,然后再注册我的组件,成功!
结论:怀疑在安装、卸载软件或使用优化软件进行系统清理的时候不小心反注册了atl.dll,导致使用atl模板创建的com组件均无法注册。
ps:两年前就遇到过此问题,当时无法搞定,只得重装系统,今天总算找到问题的原因了