关于comctl32.dll的更新(50分)

  • 主题发起人 主题发起人 Sun
  • 开始时间 开始时间
S

Sun

Unregistered / Unconfirmed
GUEST, unregistred user!
大家知道Windows的界面的显示是由comctl32.dll控制的,许多新的界面
特性(如浮动按钮)要新版本的comctl32.dll支持,怎样在安装程序里判断
comctl32.dll的版本并更新它哪?
 
我是通过wise做安装盘来实现的.把自己机器中的dll拷了一份
 
install sheilder or wise install tool都可以
 
把自己用的copy给用户,微软一向这么干。
 
我看要更新DLL有两个问题,

一个不能用老的换新的,如果已经有新的就不必再更新;
记得有GetFileVersion()等的函数可以使用。

二是如果替换。象comctl32.dll这样的DLL,WINDOWS一起动就要用它了,
所以无法在程序运行的过程中替换。应该有在WINDOWS内部专用的更新函数
或者程序的。

仅此两点看法请大家斧正。
 
2:笨办法:改AUTOEXEC.BAT,重启动,改回来
 
这样会很惨的。:)
 
Delphi4在安装时就自动检查comctl32.dll的版本,它是怎样做的哪?
 
大家查一查pegasus的回答问题,他曾经做过一个小程序来干这种事情.
 
Yeah, use 3h's GetFileVersion()
to check file version,
then you can use the util I made to ask
Windows replace critical file after system restarts.

There is source code available, :)
 
pegasus回答的问题是哪一个?
 
;昨天看了最新的《新潮电子》,好象是二月的吧,里面一篇文件应该对您有用,
它说在WINDOWS目录下有一个WININIT.EXE,在每次起动时会自动运行,它会检
查一个叫WININIT.INI的配置,如果有就执行,执行后将它改为WININIT.BAK,
而这个文件的内容决定了一些在启动前要做的事项,如将某个文件删除、改名等,
这些都适合于某些在WINDOWS中使用的文件,象我们正在讨论的comctl32.dll
一样。现在忘记是怎样写了,如果你没有订这本杂志的话我给你抄来。

由此我们可以这样做了:

1、VAR I
2、I := 检查comctl32.dll的版本
3、if I < 你要安装或要求的最低版本 then
begin
取得 WINDOWS 目录
创建修改 windows 目录下的 WinINIT.INI
重新起动
end;

现在实现起来特容易吧?
 
Yeah, 3h,
在Windows 3.x / Win 95/98下,
确实是这样做的,
在WinNT下面是通过一个Win32 API
MoveFileEx 实现的。
 
To Sun:

我回答的那个问题是dwwang提出的“ImageList的
图标问题"
 
'ImageList的图标问题 中 huaizhang 提到"MS 有一个程序专门更新
ComCtrl32.dll",不知谁有?
 
我刚刚在MFC CodeGuru上面发现了检查ComCtl32.DLL的版本的方法,
并不是通过GetFileVersion得到的! 而是直接通过检查有没有相应的
函数来进行的...
 
pegasus:
是怎样做的?
 
Sorry, I just scratch from www.codeguru.com, I have no time to
translate it into Chinese or Delphi, please read it carefully, :)

The following addition to your CWinApp class will give you this ability.

Step 1:
In your application .h file add the following just before the definition of your CWinApp-derived application class...

enum COMCTL32VERSION {
COMCTL32_UNKNOWN, COMCTL32_400, COMCTL32_470, COMCTL32_471
};

This enumeration has values for the origina Win95 COMCTL32 (v4), the IE3 COMCTL32 (v4.7) and the IE4 COMCTL32 (v4.71)

Step 2:
Add the following to your CWinApp-derived class in your application .h file...

class CMyWinApp : public CWinApp {
...
// COMCTL32 detection
private:
static COMCTL32VERSION c_nComCtl32Version;
public:
static COMCTL32VERSION ComCtl32Version();
...
};

Step 3:
Add the following to your application .cpp file...

COMCTL32VERSION CMyWinApp::c_nComCtl32Version = COMCTL32_UNKNOWN;

COMCTL32VERSION CMyWinApp::ComCtl32Version() {
// if we don't already know which version, try to find out
if (c_nComCtl32Version == COMCTL32_UNKNOWN) {
// have we loaded COMCTL32 yet?
HMODULE theModule = ::GetModuleHandle("COMCTL32");
// if so, then we can check for the version
if (theModule) {
// InitCommonControlsEx is unique to 4.7 and later
FARPROC theProc = ::GetProcAddress(theModule, "InitCommonControlsEx");
if (! theProc) {
// not found, must be 4.00
c_nComCtl32Version = COMCTL32_400;
} else {
// The following symbol are unique to 4.71
// DllInstall
// FlatSB_EnableScrollBar FlatSB_GetScrollInfo FlatSB_GetScrollPos
// FlatSB_GetScrollProp FlatSB_GetScrollRange FlatSB_SetScrollInfo
// FlatSB_SetScrollPos FlatSB_SetScrollProp FlatSB_SetScrollRange
// FlatSB_ShowScrollBar
// _DrawIndirectImageList _DuplicateImageList
// InitializeFlatSB
// UninitializeFlatSB
// we could check for any of these - I chose DllInstall
FARPROC theProc = ::GetProcAddress(theModule, "DllInstall");
if (! theProc) {
// not found, must be 4.70
c_nComCtl32Version = COMCTL32_470;
} else {
// found, must be 4.71
c_nComCtl32Version = COMCTL32_471;
}
}
}
}
return c_nComCtl32Version;
}

This function gets a handle to COMCTL32 and then looks for what functions exist within it. By looking for functions which are known NOT to be in a given version (and only in later versions), we can tell what version we actually have.

By using a static to keep the result, we do not need to keep redoing the detection logic, as once we know, the COMCTL32 cannot change from underneath us - it will stay loaded until our application terminates.

Step 4:
When using a feature that relies on a given version, you can use code like

if (CMyWinApp::ComCtl32Version() > COMCTL_400) {
// use a feature only in IE3 version or later
// like flat tool bars
}

Of course, what I do is have my own standard enhanced CWinApp-derived class which has these additions (and others) in it. The I derive each application from this enhanced class.
 
"Delphi4在安装时就自动检查comctl32.dll的版本"
问题解决的方法就在这里,Delphi4的安装程序是用installshield作的,
installshield就有此功能,
Delphi3,4所附的installshield express就可作,
只要在程序文件组中加入comctl32.dll,设定好安装目录为(winsysdir)目录,
安装程序就可自动在安装程序时检查comctl32.dll的版本,低则更新,高则不动.

 
后退
顶部