StdCopyStrBuf GetRegistryString(const char *szSubKey, const char *szValueName) { HKEY ckey; // Open the key if (RegOpenKeyExW(HKEY_CURRENT_USER, GetWideChar(szSubKey), 0, KEY_READ, &ckey)!=ERROR_SUCCESS) return StdCopyStrBuf(); // Get the value DWORD dwValSize = 128; BYTE *sValue = new BYTE[dwValSize]; while(true) { DWORD valtype; switch(RegQueryValueExW(ckey, GetWideChar(szValueName), NULL, &valtype, sValue, &dwValSize)) { case ERROR_SUCCESS: RegCloseKey(ckey); if (valtype == REG_SZ) { StdCopyStrBuf nrv(reinterpret_cast<wchar_t*>(sValue)); delete[] sValue; return nrv; } else { default: delete[] sValue; return StdCopyStrBuf(); } break; case ERROR_MORE_DATA: delete[] sValue; sValue = new BYTE[dwValSize]; break; } } }
friend T operator|( const T& lhs, const T& rhs ) noexcept( noexcept( T( lhs ), std::declval< T& >() |= rhs, T( std::declval< T& >() ) ) ) { T nrv( lhs ); nrv |= rhs; return nrv; }
friend T operator|( U&& lhs, const T& rhs ) noexcept( noexcept( T( rhs ), std::declval< T& >() |= std::move( lhs ), T( std::declval< T& >() ) ) ) { T nrv( rhs ); nrv |= std::move( lhs ); return nrv; }
friend T operator&( U&& lhs, T&& rhs ) noexcept( noexcept( T( std::move( lhs ) ), std::declval< T& >() &= std::move( rhs ), T( std::declval< T& >() ) ) ) { T nrv( std::move( lhs ) ); nrv &= std::move( rhs ); return nrv; }
friend T operator--(T& x, int) { decrementable_type nrv(x); --x; return nrv; }
friend T operator++(T& x, int) { incrementable_type nrv(x); ++x; return nrv; }