CCVersion.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #include "CCVersion.h"
  2. #include <windows.h>
  3. #include <commctrl.h>
  4. #include <shlwapi.h>
  5. DWORD GetCommCtrlDllVersion(LPCTSTR lpszDllName)
  6. {
  7. DWORD dwVersion = 0;
  8. /* In theory, we should limit the search path to only the system folder
  9. at this point, I don't care */
  10. HINSTANCE hinstDll = LoadLibraryW(lpszDllName);
  11. if(hinstDll)
  12. {
  13. DLLGETVERSIONPROC pDllGetVersion;
  14. pDllGetVersion = (DLLGETVERSIONPROC)GetProcAddress(hinstDll,
  15. "DllGetVersion");
  16. /* Because some DLLs might not implement this function, you
  17. must test for it explicitly. Depending on the particular
  18. DLL, the lack of a DllGetVersion function can be a useful
  19. indicator of the version. */
  20. if(pDllGetVersion)
  21. {
  22. DLLVERSIONINFO dvi;
  23. HRESULT hr;
  24. ZeroMemory(&dvi, sizeof(dvi));
  25. dvi.cbSize = sizeof(dvi);
  26. hr = (*pDllGetVersion)(&dvi);
  27. if(SUCCEEDED(hr))
  28. {
  29. dwVersion = PACKVERSION(dvi.dwMajorVersion, dvi.dwMinorVersion);
  30. }
  31. }
  32. FreeLibrary(hinstDll);
  33. }
  34. return dwVersion;
  35. }