It is important that when using API's that we have the correct DLL version. With codes that I use on this site I will endeavour to give you the correct DLL versions to use. In most cases this is usually not an issue and is usually operating sytem dependant. But if you need to get a Dll version then here is how. Also provided a file discription routen.
Below are actually 2 seperate codes to get
- Dll Version (either via user selection of File or listing them to a worksheet)
The Dll version is NOT an API call, it uses the File System Object.
The GetFilediscription DOES use API's, I have included them together so you can use these in combination ie getting a file discription and the Version IF any.
Amendment: Extra:
The File discription uses the;
Type structure taken fron the C Header file > shellapi.h
and looks like this;
typedef struct _SHFILEINFO {
HICON hIcon;
int iIcon;
DWORD dwAttributes;
TCHAR szDisplayName[MAX_PATH];
TCHAR szTypeName[80];
} SHFILEINFO;
From this we can now build our VBA structure as follows;
Private Type SHFILEINFO
hIcon As Long
iIcon As Long
dwAttributes As Long
szDisplayName As String * MAX_PATH
szTypeName As String * 80
End Type
The API that we will use is;
Private Declare Function SHGetFileInfo Lib "Shell32" _
Alias "SHGetFileInfoA" ( _
ByVal pszPath As Any, _
ByVal dwFileAttributes As Long, _
psfi As SHFILEINFO, _
ByVal cbFileInfo As Long, _
ByVal uFlags As Long) As Long
Note this is one of the core Windows DLL and represents the objects in the Shell. Methods are provided to control the Shell and to execute commands within the Shell. There are also methods to obtain other Shell-related objects.
DLL Version Numbers
Most of the programming elements in the Shell and common controls documentation are contained in three DLLs: Comctl32.dll, Shell32.dll, and Shlwapi.dll.
Latter on I will discuss more about the other 2 DLLs.
The plus side of Windows OS is that enhancements are just a matter of updating DLLs, so as you would expect, different versions of these DLLs implement different features. Below is the version numbers which indicates that the programming element was first implemented in that version and will also be found in all subsequent versions of the DLL. If no version number is specified, the programming element is implemented in all versions. The following list outlines the different DLL versions and how they were distributed.
Version
DLL
Distribution Platform
- 4.0
All
Microsoft® Windows® 95/Microsoft Windows NT® 4.0.
- 4.7
All
Microsoft Internet Explorer 3.x.
- 4.71
All
Internet Explorer 4.0.
- 4.72
All
Internet Explorer 4.01 and Windows 98
- 5.0
Shlwapi.dll
Internet Explorer 5
- 6.0
Shlwapi.dll
Internet Explorer 6 and Windows XP.
- 5.0
Shell32.dll
Windows 2000 and Windows Millennium
Edition (Windows Me)
- 6.0
Shell32.dll
Windows XP.
- 5.8
Comctl32.dll
Internet Explorer 5.
- 5.81 Comctl32.dll
Windows 2000 and Windows Me
- 6.0
Comctl32.dll
Windows XP
Note: Minimum operating systems required for above API
Windows NT 4.0, Windows 95