Contents Index Topic Contents | ||
Previous Topic: DLL Versioning Next Topic: DLLGETVERSIONPROC |
DllGetVersion
HRESULT CALLBACK DllGetVersion( DLLVERSIONINFO *pdvi );Implemented by many of the Windows shell DLLs to provide a method for obtaining DLL-specific version information. This function is not an API, but it is exported by name from the DLL.
To call this function, use the LoadLibrary and GetProcAddress functions to obtain the function pointer. The DLLGETVERSIONPROC type is used as the data type for the function pointer. For more information, see the comments at the end of this reference.
- Returns NOERROR if successful, or an OLE-defined error value otherwise.
- pdvi
- Address of a DLLVERSIONINFO structure that receives the version information. The cbSize member must be filled in before calling the function.
Because different DLLs implement this function, it is necessary to call LoadLibrary to obtain the instance handle to the DLL and then call GetProcAddress to obtain the function pointer. The following example shows a function that will attempt to use DllGetVersion for the supplied DLL and display the version information in a message box:
void GetDllVersion(LPCTSTR lpszDllName) { HINSTANCE hinstDll; TCHAR szText[MAX_PATH] = TEXT("Could not load DLL"); //Load the DLL. hinstDll = LoadLibrary(lpszDllName); if(hinstDll) { DLLGETVERSIONPROC pDllGetVersion; /* You must get this function explicitly because the DLL might not implement the function. Depending upon the DLL, the lack of implementation of the function may be a version marker in itself. */ pDllGetVersion = (DLLGETVERSIONPROC)GetProcAddress( hinstDll, TEXT("DllGetVersion")); if(pDllGetVersion) { DLLVERSIONINFO dvi; HRESULT hr; ZeroMemory(&dvi, sizeof(dvi)); dvi.cbSize = sizeof(dvi); hr = (*pDllGetVersion)(&dvi); if(SUCCEEDED(hr)) { wsprintf( szText, TEXT("DLL Version = %d.%02d\nBuild# = %d\n"), dvi.dwMajorVersion, dvi.dwMinorVersion, dvi.dwBuildNumber); switch(dvi.dwPlatformID) { case DLLVER_PLATFORM_WINDOWS: lstrcat(szText, TEXT("Platform is Windows")); break; case DLLVER_PLATFORM_NT: lstrcat(szText, TEXT("Platform is Windows NT")); break; default: lstrcat(szText, TEXT("Platform is not defined")); break; } } else { lstrcpy( szText, TEXT("DllGetVersion Failed - Cannot determine DLL version.")); } } else { //If GetProcAddress failed, the DLL does not implement DllGetVersion. lstrcpy( szText, TEXT("GetProcAddress Failed - The DLL does not implement DllGetVersion.")); } FreeLibrary(hinstDll); } else { lstrcpy(szText, TEXT("Could not load the DLL")); } MessageBox(NULL, szText, lpszDllName, MB_OK | MB_ICONINFORMATION); }Currently, most of the Windows shell DLLs implement DllGetVersion. These include, but are not limited to, Shell32.dll, Comctl32.dll, Shdocvw.dll, and Shlwapi.dll.
Top of Page
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.