The new vbAccelerator Site - more VB and .NET Code and Controls
Source Code
2 Common Controls Library &nbsp

Find Out Which COMCTL32.DLL Version You Have

Use this code to work out which of the sexy common controls features your target system will support

Internet Explorer 5 Installed

Download Code
Download the Common Controls Version code (7kb)

As you will read from my other Common Controls project the facilities provided by COMCTL32.DLL depend on what version you have installed. This sample covers the VB code you need to find out what version is installed on a user's machine.

Version checking is achieved using by first checking whether the DLLGetVersion function is exported by the library. If it isn't, this means you have a pre Internet Explorer version, i.e. 4.0. If the function is exported, the code calls it and returns the version number and build.

Here is the source for the ComCtlVersion function:

Private Const S_OK = &H0
&nbsp &nbsp cbSize As Long
&nbsp &nbsp dwMajor As Long
&nbsp &nbsp dwMinor As Long
&nbsp &nbsp dwBuildNumber As Long
&nbsp &nbsp dwPlatformID As Long
End Type
Private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long
Private Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As Long
Private Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As Long, ByVal lpProcName As String) As Long
Private Declare Function DllGetVersion Lib "comctl32" (pdvi As DLLVERSIONINFO) As Long

Public Function ComCtlVersion( _
&nbsp &nbsp &nbsp &nbsp ByRef lMajor As Long, _
&nbsp &nbsp &nbsp &nbsp ByRef lMinor As Long, _
&nbsp &nbsp &nbsp &nbsp Optional ByRef lBuild As Long _
&nbsp &nbsp ) As Boolean
Dim hMod As Long
Dim lR As Long
Dim lptrDLLVersion As Long

&nbsp &nbsp lMajor = 0: lMinor = 0: lBuild = 0

&nbsp &nbsp hMod = LoadLibrary("comctl32.dll")
&nbsp &nbsp If (hMod 0) Then
&nbsp &nbsp &nbsp &nbsp lR = S_OK
&nbsp &nbsp &nbsp &nbsp '/*
&nbsp &nbsp &nbsp &nbsp ' You must get this function explicitly because earlier versions of the DLL
&nbsp &nbsp &nbsp &nbsp ' don't implement this function. That makes the lack of implementation of the
&nbsp &nbsp &nbsp &nbsp ' function a version marker in itself. */
&nbsp &nbsp &nbsp &nbsp lptrDLLVersion = GetProcAddress(hMod, "DllGetVersion")
&nbsp &nbsp &nbsp &nbsp If (lptrDLLVersion 0) Then
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp tDVI.cbSize = Len(tDVI)
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp lR = DllGetVersion(tDVI)
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp If (lR = S_OK) Then
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp lMajor = tDVI.dwMajor
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp lMinor = tDVI.dwMinor
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp lBuild = tDVI.dwBuildNumber
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp End If
&nbsp &nbsp &nbsp &nbsp Else
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp 'If GetProcAddress failed, then the DLL is a version previous to the one
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp 'shipped with IE 3.x.
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp lMajor = 4
&nbsp &nbsp &nbsp &nbsp End If
&nbsp &nbsp &nbsp &nbsp FreeLibrary hMod
&nbsp &nbsp &nbsp &nbsp ComCtlVersion = True
&nbsp &nbsp End If

End Function

TopBack to top
Source Code - What We're About!Back to Source Code


AboutContributeSend FeedbackPrivacy

Copyright 1998-1999, Steve McMahon ( All Rights Reserved.
Last updated: 22 November 1998