CKeyTransformBCrypt::CKeyTransformBCrypt() { if(m_bEnableBCrypt == FALSE) { m_hLib = NULL; return; } // BCrypt.dll is only supported on >= Vista if(AU_IsAtLeastWinVistaSystem() == FALSE) { m_hLib = NULL; return; } m_hLib = AU_LoadLibrary(BCRYPT_DLLNAME); if(m_hLib == NULL) return; m_lpBCryptOpenAlgorithmProvider = (LPBCRYPTOPENALGORITHMPROVIDER) GetProcAddress(m_hLib, BCFN_OAP); m_lpBCryptCloseAlgorithmProvider = (LPBCRYPTCLOSEALGORITHMPROVIDER) GetProcAddress(m_hLib, BCFN_CAP); m_lpBCryptGetProperty = (LPBCRYPTGETPROPERTY)GetProcAddress(m_hLib, BCFN_GP); m_lpBCryptSetProperty = (LPBCRYPTSETPROPERTY)GetProcAddress(m_hLib, BCFN_SP); m_lpBCryptGenerateSymmetricKey = (LPBCRYPTGENERATESYMMETRICKEY) GetProcAddress(m_hLib, BCFN_GSK); m_lpBCryptImportKey = (LPBCRYPTIMPORTKEY)GetProcAddress(m_hLib, BCFN_IK); m_lpBCryptDestroyKey = (LPBCRYPTDESTROYKEY)GetProcAddress(m_hLib, BCFN_DK); m_lpBCryptEncrypt = (LPBCRYPTENCRYPT)GetProcAddress(m_hLib, BCFN_E); if((m_lpBCryptOpenAlgorithmProvider == NULL) || (m_lpBCryptCloseAlgorithmProvider == NULL) || (m_lpBCryptGetProperty == NULL) || (m_lpBCryptSetProperty == NULL) || (m_lpBCryptGenerateSymmetricKey == NULL) || (m_lpBCryptImportKey == NULL) || (m_lpBCryptDestroyKey == NULL) || (m_lpBCryptEncrypt == NULL)) { ASSERT(FALSE); this->_FreeLib(); } }
bool CCustomComboBoxEx::_CanHandleKey(TCHAR tchKey) { // The feature is supported natively by Windows Vista if(AU_IsAtLeastWinVistaSystem() == TRUE) return false; return ((tchKey >= _T('A')) && (tchKey <= _T('Z'))); }
BOOL NewGUI_GetNonClientMetrics(NONCLIENTMETRICS* p) { if(p == NULL) { ASSERT(FALSE); return FALSE; } UINT cbSize = sizeof(NONCLIENTMETRICS); ZeroMemory(p, cbSize); // See the documentation of the NONCLIENTMETRICS structure: // https://msdn.microsoft.com/en-us/library/windows/desktop/ff729175.aspx // https://www.codeproject.com/Messages/3989684/Compile-with-dev-studio-running-on-Windows-XP.aspx #if (WINVER == 0x0600) if(AU_IsAtLeastWinVistaSystem() == FALSE) { BOOST_STATIC_ASSERT(sizeof(p->iPaddedBorderWidth) == sizeof(int)); cbSize -= sizeof(int); } #else // Verify that the size computation above is still correct with the // latest NONCLIENTMETRICS definition, then update the WINVER comparison // BOOST_STATIC_ASSERT(false); #endif p->cbSize = cbSize; return SystemParametersInfo(SPI_GETNONCLIENTMETRICS, cbSize, p, 0); }
CShutdownBlocker::CShutdownBlocker(HWND hWnd, LPCTSTR lpReason) { ASSERT(hWnd != NULL); m_hWnd = hWnd; if(AU_IsAtLeastWinVistaSystem() == FALSE) { m_hLib = NULL; return; } m_hLib = LoadLibrary(_T("User32.dll")); if(m_hLib == NULL) { ASSERT(FALSE); return; } m_lpSdrCreate = (LPSHUTDOWNBLOCKREASONCREATE)GetProcAddress(m_hLib, "ShutdownBlockReasonCreate"); m_lpSdrDestroy = (LPSHUTDOWNBLOCKREASONDESTROY)GetProcAddress(m_hLib, "ShutdownBlockReasonDestroy"); if((m_lpSdrCreate == NULL) || (m_lpSdrDestroy == NULL)) { ASSERT(FALSE); Release(); return; } if(g_psdbPrimary != NULL) return; std::basic_string<WCHAR> str; if((lpReason != NULL) && (lpReason[0] != 0)) str = _StringToUnicodeStl(lpReason); else { ASSERT(FALSE); str = L"..."; } if(m_lpSdrCreate(hWnd, str.c_str()) != FALSE) g_psdbPrimary = this; else { ASSERT(FALSE); } }
void NewGUI_SetCueBanner_TB(HWND hTextBox, LPCTSTR lpText) { ASSERT(lpText != NULL); if(lpText == NULL) return; // On Windows XP there's a drawing bug at the left border (text is // not displayed correctly), therefore prepend a space on Windows XP CString strSearchTr = ((AU_IsAtLeastWinVistaSystem() == FALSE) ? _T(" ") : _T("")); strSearchTr += lpText; #ifndef _UNICODE LPCWSTR pSearchUni = _StringToUnicode(strSearchTr); #else // Unicode LPCWSTR pSearchUni = strSearchTr; #endif ::SendMessage(hTextBox, EM_SETCUEBANNER, 0, (LPARAM)pSearchUni); #ifndef _UNICODE SAFE_DELETE_ARRAY(pSearchUni); #endif }