コード例 #1
0
void BrowserFactory::GetIEVersion() {
  LOG(TRACE) << "Entering BrowserFactory::GetIEVersion";

  struct LANGANDCODEPAGE {
    WORD language;
    WORD code_page;
    } *lpTranslate;

  DWORD dummy;
  DWORD length = ::GetFileVersionInfoSize(this->ie_executable_location_.c_str(),
                                          &dummy);
  if (length == 0) {
    // 64-bit Windows 8 has a bug where it does not return the executable location properly
    this->ie_major_version_ = -1;
    LOG(WARN) << "Couldn't find IE version for executable "
               << LOGWSTRING(this->ie_executable_location_.c_str())
               << ", falling back to "
               << this->ie_major_version_;
    return;
  }
  std::vector<BYTE> version_buffer(length);
  ::GetFileVersionInfo(this->ie_executable_location_.c_str(),
                       dummy,
                       length,
                       &version_buffer[0]);

  UINT page_count;
  BOOL query_result = ::VerQueryValue(&version_buffer[0],
                                      FILE_LANGUAGE_INFO,
                                      reinterpret_cast<void**>(&lpTranslate),
                                      &page_count);
    
  wchar_t sub_block[MAX_PATH];
  _snwprintf_s(sub_block,
               MAX_PATH,
               MAX_PATH,
               FILE_VERSION_INFO,
               lpTranslate->language,
               lpTranslate->code_page);
  LPVOID value = NULL;
  UINT size;
  query_result = ::VerQueryValue(&version_buffer[0],
                                 sub_block,
                                 &value,
                                 &size);
  std::wstring ie_version;
  ie_version.assign(static_cast<wchar_t*>(value));
  std::wstringstream version_stream(ie_version);
  version_stream >> this->ie_major_version_;
}
コード例 #2
0
void BrowserFactory::GetIEVersion() {
  LOG(TRACE) << "Entering BrowserFactory::GetIEVersion";

  std::string ie_version = FileUtilities::GetFileVersion(this->ie_executable_location_);
  
  if (ie_version.size() == 0) {
    // 64-bit Windows 8 has a bug where it does not return the executable location properly
    this->ie_major_version_ = -1;
    LOG(WARN) << "Couldn't find IE version for executable "
               << LOGWSTRING(this->ie_executable_location_)
               << ", falling back to "
               << this->ie_major_version_;
    return;
  }

  std::stringstream version_stream(ie_version);
  version_stream >> this->ie_major_version_;
}
コード例 #3
0
void BrowserFactory::GetIEVersion() {
  struct LANGANDCODEPAGE {
    WORD language;
    WORD code_page;
    } *lpTranslate;

  DWORD dummy;
  DWORD length = ::GetFileVersionInfoSize(this->ie_executable_location_.c_str(),
                                          &dummy);
  std::vector<BYTE> version_buffer(length);
  ::GetFileVersionInfo(this->ie_executable_location_.c_str(),
                       dummy,
                       length,
                       &version_buffer[0]);

  UINT page_count;
  BOOL query_result = ::VerQueryValue(&version_buffer[0],
                                      FILE_LANGUAGE_INFO,
                                      reinterpret_cast<void**>(&lpTranslate),
                                      &page_count);
    
  wchar_t sub_block[MAX_PATH];
    _snwprintf_s(sub_block,
                 MAX_PATH,
                 MAX_PATH,
                 FILE_VERSION_INFO,
                 lpTranslate->language,
                 lpTranslate->code_page);
    LPVOID value = NULL;
    UINT size;
    query_result = ::VerQueryValue(&version_buffer[0],
                                   sub_block,
                                   &value,
                                   &size);
  std::wstring ie_version;
  ie_version.assign(static_cast<wchar_t*>(value));
  std::wstringstream version_stream(ie_version);
  version_stream >> this->ie_major_version_;
}