山寨:不是最好的,是最适合我们的!欢迎体验山寨 中文版MSDN

Blog @ Blog

当华美的叶片落尽,生命的脉络才历历可见。 -- 聂鲁达

常用链接

统计

积分与排名

BBS

Blog

Web

最新评论

VS2005环境ATL工程报错:error C2065: “_Module”: 未声明的标识符

写在前面:
       最近在接触office编程,使用vc6.0环境Debug能编译通过,但是ReleaseUMinDependenc编译就报错libcmtd.lib(crt0.obj) : error LNK2001: unresolved external symbol _这个问题还没有解决。希望通过CSDN有高手指点,日后再总结6.0环境这个问题。高手门都建议学习ATL COM最好使用VS2005。折腾半天还是遇见这个错误,这个错误又折腾半天!通过Google有问题你就个google)找到CSDN有朋友遇见同样的问题!他的描述如下也是我要表达的):
VC6.0中用ATL生成的全局变量_Module, 
  CComModule  _Module; 
  可以调用_Module.GetResourceInstance(); 
   
  用VS2005生成时为_AtlModule, 
  COutLookAddinModule  _AtlModule 
  不能调用GetResourceInstance();怎么办?
在所有回复中没有找到答案!但是通过QQ技术群平台和Google还有百度找到一些方向!
1、VS2005的wizard生成ATL后,发现VS2005会用子类模板化的_AtlModule代替原来VC6.0的_Module
2、VS2005中 ATL 7.0取代了vc6.0中的 ATL 3.0。
3、MSDN英文中有提到CAtlBaseModule   Contains information required by most applications that use ATL. Contains the HINSTANCE of the module and the resource instance.
也就是说要使用GetResourceInstance();  必须派生于CAtlBaseModule 。结果自作聪明到处定义CAtlBaseModule  _Module。结果有不少新的错误!还好我在CSDN发帖有问直接告诉我了!直接使用_AtlBaseModule,微软已经为我们定义好了!在atlcore.h定义了extern CAtlBaseModule _AtlBaseModule;
示例如下:

// 设置位图按钮风格,位图为x32大小,将其放入剪切板中用PasteFace()贴在指定按钮上
        HBITMAP hBmp =(HBITMAP)::LoadImage(_AtlBaseModule.GetResourceInstance(),
            MAKEINTRESOURCE(IDB_BITMAP),IMAGE_BITMAP,
0,0,LR_LOADMAP3DCOLORS);


附一:
Earlier versions of ATL used CComModule. In ATL 7.0, CComModule functionality is replaced by several classes:

CAtlBaseModule   Contains information required by most applications that use ATL. Contains the HINSTANCE of the module and the resource instance.

CAtlComModule   Contains information required by the COM classes in ATL.

CAtlWinModule   Contains information required by the windowing classes in ATL.

CAtlDebugInterfacesModule   Contains support for interface debugging.

CAtlModule   The following CAtlModule-derived classes are customized to contain information required in a particular application type. Most members in these classes can be overridden:

CAtlDllModuleT   Used in DLL applications. Provides code for the standard exports.

CAtlExeModuleT   Used in EXE applications. Provides code required in an EXE.

CAtlServiceModuleT   Provides support to create Windows NT and Windows 2000 Services.

CComModule is still available for backward compatibility.
Earlier versions of ATL used CComModule. In ATL 7.0, CComModule functionality is replaced by several classes:

CAtlBaseModule   Contains information required by most applications that use ATL. Contains the HINSTANCE of the module and the resource instance.

CAtlComModule   Contains information required by the COM classes in ATL.

CAtlWinModule   Contains information required by the windowing classes in ATL.

CAtlDebugInterfacesModule   Contains support for interface debugging.

CAtlModule   The following CAtlModule-derived classes are customized to contain information required in a particular application type. Most members in these classes can be overridden:

CAtlDllModuleT   Used in DLL applications. Provides code for the standard exports.

CAtlExeModuleT   Used in EXE applications. Provides code required in an EXE.

CAtlServiceModuleT   Provides support to create Windows NT and Windows 2000 Services.

CComModule is still available for backward compatibility.

附二(写在前面提及的错误,目前还没有找到答案!贴出来希望有高手能指点):
ATL 工程 中ReleaseUMinDependency与 Debug区别是什么?
Debug可以编译通过
ReleaseUMinDependency编译报错
Linking...
  Creating library ReleaseUMinDependency/WordCOM.lib and object ReleaseUMinDependency/WordCOM.exp
LIBCMT.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
ReleaseUMinDependency/WordCOM.dll : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

WordCOM.dll - 2 error(s), 0 warning(s)

注意:
查资料反馈
libcmtd.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
这个错误的修改方法如下:
Windows项目要使用Windows子系统, 而不是Console, 可以这样设置
[Project] --> [Settings] --> 选择"Link"属性页
在Project Options中将/subsystem:console改成/subsystem:windows 

可是我这边这个参数没有错:
kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /incremental:no /pdb:"ReleaseUMinDependency/OutLookAddin.pdb" /machine:I386 /def:".\OutLookAddin.def" /out:"ReleaseUMinDependency/OutLookAddin.dll" /implib:"ReleaseUMinDependency/OutLookAddin.lib"
是不是因为我的工程不是 MFC而是ATL,还有其他地方有错误!
第2个错误也没有找到具体的静态库!
希望大家帮帮我!
基本完成office编程(Outlook)的示例程序link

posted on 2008-10-17 23:27 isabc 阅读(4512) 评论(0)  编辑 收藏 引用 所属分类: BUG分析


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


广告信息(免费广告联系)

中文版MSDN:
欢迎体验