Introduction
With each Windows operating system update, and each update of Internet Explorer,
we are issued with a new version of the system libraries Comctl32.dll, Shell32.dll,
and Shlwapi.dll. These libraries contain the bulk of the code that handles the
common control and shell functionality of windows. The problem is, each version is
different, and it can sometimes be critical to know which platform you are
targeting when writing software that specifically uses functionality in these
libraries.
Below is a list of library versions, and the platforms you would expect to find
these versions.
Version | Distribution platform |
4.00 | Microsoft Windows 95/Windows NT 4.0 |
4.70 | Microsoft Internet Explorer 3.x |
4.71 | Microsoft Internet Explorer 4.0 |
4.72 | Microsoft Internet Explorer 4.01 and Windows 98 |
5.00 | Microsoft Windows 2000 and Internet Explorer 5
|
There are a couple of points here:
Firstly, For Windows 95, Internet Explorer 4.0 can be installed without the integrated
shell. Thus, you may have either version 4.71 or 4.72 of Comctl32.dll or Shlwapi.dll
on a Windows 95 box, but the version of Shell32.dll may be different. On a Windows 98
system all three libraries will have the same value.
Secondly, Internet Explorer will update Comctl32.dll and Shlwapi.dll to version 5.0,
but will not update the Shell32.dll library. Thus, if you install IE 5 on a non-Windows
2000 system, your Shell32.dll version will again be different to your Comctl32.dll and
Shlwapi.dll versions.
So how do you test?
Microsoft kindly provides us with a handy function to test for the various
flavours.
#define PACKVERSION(major,minor) MAKELONG(minor,major)
DWORD GetDllVersion(LPCTSTR lpszDllName)
{
HINSTANCE hinstDll;
DWORD dwVersion = 0;
hinstDll = LoadLibrary(lpszDllName)
if(hinstDll)
{
DLLGETVERSIONPROC pDllGetVersion;
pDllGetVersion = (DLLGETVERSIONPROC) GetProcAddress(hinstDll, "DllGetVersion");
if(pDllGetVersion)
{
DLLVERSIONINFO dvi;
HRESULT hr;
ZeroMemory(&dvi, sizeof(dvi));
dvi.cbSize = sizeof(dvi);
hr = (*pDllGetVersion)(&dvi);
if(SUCCEEDED(hr))
{
dwVersion = PACKVERSION(dvi.dwMajorVersion, dvi.dwMinorVersion);
}
}
FreeLibrary(hinstDll);
}
return dwVersion;
}
It's noted that the above will work only for version 4.71 and above of the libraries.
Oh well...
So - to use the above function in your code, you would do something like the following:
if (GetDllVersion(TEXT("comctl32.dll")) >= PACKVERSION(4,71))
{
}
else
{
}
Chris Maunder is the co-founder of
CodeProject, DeveloperMedia and ContentLab, and has been a prominent figure in the software development community for nearly 30 years. Hailing from Australia, Chris has a background in Mathematics, Astrophysics, Environmental Engineering and Defence Research. His programming endeavours span everything from FORTRAN on Super Computers, C++/MFC on Windows, through to to high-load .NET web applications and Python AI applications on everything from macOS to a Raspberry Pi. Chris is a full-stack developer who is as comfortable with SQL as he is with CSS.
In the late 1990s, he and his business partner David Cunningham recognized the need for a platform that would facilitate knowledge-sharing among developers, leading to the establishment of CodeProject.com in 1999. Chris's expertise in programming and his passion for fostering a collaborative environment have played a pivotal role in the success of CodeProject.com. Over the years, the website has grown into a vibrant community where programmers worldwide can connect, exchange ideas, and find solutions to coding challenges. Chris is a prolific contributor to the developer community through his articles and tutorials, and his latest passion project,
CodeProject.AI.
In addition to his work with CodeProject.com, Chris co-founded ContentLab and DeveloperMedia, two projects focussed on helping companies make their Software Projects a success. While at CodeProject, Chris' roles included Architecture and coding, Product Development, Content Creation, Community Growth, Client Satisfaction and Systems Automation, and many, many sales meetings. All while keeping his sense of humour.