MCPcopy Create free account
hub / github.com/NetHack/NetHack / GetComCtlVersion

Function GetComCtlVersion

win/win32/NetHackW.c:308–353  ·  view source on GitHub ↗

Get the version of the Common Control library on this machine. Copied from the Microsoft SDK */

Source from the content-addressed store, hash-verified

306 Copied from the Microsoft SDK
307 */
308HRESULT
309GetComCtlVersion(LPDWORD pdwMajor, LPDWORD pdwMinor)
310{
311 HINSTANCE hComCtl;
312 HRESULT hr = S_OK;
313 DLLGETVERSIONPROC pDllGetVersion;
314
315 if (IsBadWritePtr(pdwMajor, sizeof(DWORD))
316 || IsBadWritePtr(pdwMinor, sizeof(DWORD)))
317 return E_INVALIDARG;
318 // load the DLL
319 hComCtl = LoadLibrary(TEXT("comctl32.dll"));
320 if (!hComCtl)
321 return E_FAIL;
322
323 /*
324 You must get this function explicitly because earlier versions of the DLL
325 don't implement this function. That makes the lack of implementation of
326 the
327 function a version marker in itself.
328 */
329 pDllGetVersion =
330 (DLLGETVERSIONPROC) GetProcAddress(hComCtl, TEXT("DllGetVersion"));
331 if (pDllGetVersion) {
332 DLLVERSIONINFO dvi;
333 ZeroMemory(&dvi, sizeof(dvi));
334 dvi.cbSize = sizeof(dvi);
335 hr = (*pDllGetVersion)(&dvi);
336 if (SUCCEEDED(hr)) {
337 *pdwMajor = dvi.dwMajorVersion;
338 *pdwMinor = dvi.dwMinorVersion;
339 } else {
340 hr = E_FAIL;
341 }
342 } else {
343 /*
344 If GetProcAddress failed, then the DLL is a version previous to the
345 one
346 shipped with IE 3.x.
347 */
348 *pdwMajor = 4;
349 *pdwMinor = 0;
350 }
351 FreeLibrary(hComCtl);
352 return hr;
353}
354
355/* apply bitmap pointed by sourceDc transparently over
356bitmap pointed by hDC */

Callers 1

WinMainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected