Chinaunix首页 | 论坛 | 博客
  • 博客访问: 153944
  • 博文数量: 37
  • 博客积分: 2510
  • 博客等级: 少校
  • 技术积分: 380
  • 用 户 组: 普通用户
  • 注册时间: 2008-08-13 18:49
文章分类

全部博文(37)

文章存档

2010年(1)

2009年(19)

2008年(17)

我的朋友

分类:

2009-09-04 17:33:43

comctl32.dll

今天 用SysLink Control ..没有想到还真麻烦...按照常规方法..竟然对话框都不会显示 ..
费了几个小时...在google.中也搜索了好半天...总把问题搞定..(网上有类似的一篇文章...)


1.WinXP SP3 中comctl32.dll的版本
C:\WINDOWS\system32  版本: 5.82.2900.5512

C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.0.0_x-ww_1382d70a
版本: 6.0.0.0

C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9
版本: 6.0.2600.2180

C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.5512_x-ww_35d4ce83
版本: 6.0.2600.5512

2.我们的程序..
我们的程序通常是这样的..

 INITCOMMONCONTROLSEX InitCtrls;


 InitCtrls.dwSize = sizeof(InitCtrls);


 // Set this to include all the common control classes you want to use
 // in your application.
 InitCtrls.dwICC = ICC_LINK_CLASS;


 BOOL f = InitCommonControlsEx(&InitCtrls);(这里断点)

 int m = GetLastError();

我的M的值竟然是0..但是f 的值也是0..就是返回false/ 这表明InitCommonControlsEx没有成功...


不知道为什么...难道真像网上有篇文章说..InitCommonControlsEx没有用SetLastError 设置erorcode...

把我们的程序断下来,,,用 Process Explorer (下载地址:)查看..

找到devenv.exe(VS2008)进程..下载有我们的程序的进程..选中这个进程..下面就会列出所加载的模块..
找到 COMCTL32.dll (Common Controls Library   ) 后面的version ..显示:5.82.2900.5512..显示不是加载的6.0的版本.(这边是问题的所在.)

见MSDN(ms-help://MS.MSDNQTR.v90.en/shellcc/platform/commctls/syslink/syslinkovrvw.htm):
The SysLink control is defined in the ComCtl32.dll version 6 and
requires a manifest that specifies that version 6 of the DLL should be used if it is available.
 (这个控件在版本为6 的comctl.dll中定义.
需要用manifest 指定版本号,,否则不起作用.. )

解决办法:
1.
#include  
#pragma   comment(lib,   "comctl32.lib ")
2.
InitCommonControls
3.

添加一个文件 app.config 将下面的内容粘贴进去(下面的内容是从MSDN中拷的...为什么这样..我们就不去研究了..微软的东西向来都是很麻烦了.). 内容如下.



    version="1.0.0.0"
    processorArchitecture="X86"
    name="CompanyName.ProductName.YourApplication"
    type="win32"
/>
Your application description here.

   
                    type="win32"
            name="Microsoft.Windows.Common-Controls"
            version="6.0.0.0"
            processorArchitecture="X86"
            publicKeyToken="6595b64144ccf1df"
            language="*"
        />
   


4.工程属性->Configuration Properties->Manifest Tool->Input and Output"->"Additional Manifest Files"  然后输入

app.config.保存就OK了..(我的VS2008 是英文版的)

最后,我们在用Process Explorer  查看一下...发现此时版本..6.0.2900.5512,,这下,,应该就没有总是...

从上面可以看到. ..XP系统默认不会加载WinSxS下的文件的...要加载...就要用配置文件...它只加载System32下的那个comctl32.dll ...

阅读(4345) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~