MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / GetVersion

Function GetVersion

src/utilities/install/install.cpp:407–463  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

405namespace {
406
407USHORT GetVersion(const TEXT* filename, DWORD& verMS, DWORD& verLS, err_handler_t err_handler)
408{
409/**************************************
410 *
411 * G e t V e r s i o n
412 *
413 **************************************
414 *
415 * Functional description
416 * Get the file version of a dll whose full path and name is given.
417 * Returns a status value to report a failure, a non-existing file or success.
418 * 'version' is only updated in case of success.
419 *
420 **************************************/
421
422 HANDLE hfile = CreateFile(filename, GENERIC_READ,
423 FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0);
424 if (hfile == INVALID_HANDLE_VALUE)
425 return FB_INSTALL_FILE_NOT_FOUND;
426
427 // We'll keep hfile opened until we have read version so that the file
428 // can't be deleted between check for existence and version read.
429
430 DWORD dwUnused;
431 DWORD rsize = GetFileVersionInfoSize(const_cast<TEXT*>(filename), &dwUnused);
432 if (rsize == 0)
433 {
434 ULONG werr = GetLastError();
435 CloseHandle(hfile);
436 return (*err_handler) (werr, "GetFileVersionInfoSize()");
437 }
438
439 BYTE* hver = new BYTE[rsize];
440 if (! GetFileVersionInfo(const_cast<TEXT*>(filename), 0, rsize, hver))
441 {
442 ULONG werr = GetLastError();
443 delete[] hver;
444 CloseHandle(hfile);
445 return (*err_handler) (werr, "GetFileVersionInfo()");
446 }
447 CloseHandle(hfile); // Not needed anymore
448
449 VS_FIXEDFILEINFO* ffi;
450 UINT uiUnused;
451 if (! VerQueryValue(hver, "\\", (void**)&ffi, &uiUnused))
452 {
453 ULONG werr = GetLastError();
454 delete[] hver;
455 return (*err_handler) (werr, "VerQueryValue()");
456 }
457
458 verMS = ffi->dwFileVersionMS;
459 verLS = ffi->dwFileVersionLS;
460
461 delete[] hver;
462 return FB_SUCCESS;
463}
464

Callers 4

CLIENT_installFunction · 0.85
CLIENT_removeFunction · 0.85
CLIENT_queryFunction · 0.85
isGlobalKernelPrefixFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected