Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Visual Basic
Expertise: Advanced
Jan 13, 1999

Yeah, But Which Common Controls?

This fragment of code from the VB standard module shows the GetComCtlVersion function that retrieves the major and minor version numbers of the Comctl32.dll installed on the local system. Use this function when you subclass toolbar or listview controls from Comctl32.ocx and implement hot-tracking toolbar or full-row select in the listview. It's also useful when checking the DLL version in your setup application:
 
VersionDistribution Platform 
4.00	Microsoft Windows 95/Windows NT 4.0 
4.70	Microsoft Internet Explorer 3.0x 
4.71	Microsoft Internet Explorer 4.00 
4.72	Microsoft Internet Explorer 4.01 

Option Explicit 

Private Const S_OK = &H0 

Private Declare Function LoadLibrary Lib "kernel32" _ 
	Alias "LoadLibraryA" (ByVal lpLibFileName As String) _
	As Long 
Private Declare Function GetProcAddress Lib "kernel32" _
	(ByVal hModule As Long, ByVal lpProcName As String) As _
	Long 
Private Declare Function FreeLibrary Lib "kernel32" ( _ 
	ByVal hLibModule As Long) As Long 
Private Declare Function DllGetVersion Lib "comctl32.dll" _
	(pdvi As DLLVERSIONINFO) As Long 

Private Type DLLVERSIONINFO 
	cbSize As Long 
	dwMajorVersion As Long 
	dwMinorVersion As Long 
	dwBuildNumber As Long 
	dwPlatformID As Long 
End Type 

Public Function GetComCtlVersion(nMajor As Long, nMinor As _
	Long) As Boolean 
	Dim hComCtl As Long 
	Dim hResult As Long 
	Dim pDllGetVersion As Long 
	Dim dvi As DLLVERSIONINFO 

	hComCtl = LoadLibrary("comctl32.dll") 
	If hComCtl <> 0 Then 
	hResult = S_OK 
	pDllGetVersion = GetProcAddress(hComCtl, _
		"DllGetVersion") 
		If pDllGetVersion <> 0 Then 
			dvi.cbSize = Len(dvi) 
			hResult = DllGetVersion(dvi) 
		If hResult = S_OK Then 
				nMajor = dvi.dwMajorVersion 
				nMinor = dvi.dwMinorVersion 
			End If 
		End If 
		Call FreeLibrary(hComCtl) 
		GetComCtlVersion = True 
	End If 
End Function
Lubomir Bruha
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date