Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
mhogomchungu committed Nov 20, 2024
2 parents ddc8999 + d3ba72d commit 31fd6be
Showing 1 changed file with 35 additions and 27 deletions.
62 changes: 35 additions & 27 deletions src/utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ void utility::windowsSetDarkModeTitleBar( const Context& ctx )
}
}

std::vector< utility::PlayerOpts > utility::getMediaPlayers()
std::vector< utility::PlayerOpts > _getMediaPlayers( REGSAM wow )
{
class buffer
{
Expand Down Expand Up @@ -401,10 +401,13 @@ std::vector< utility::PlayerOpts > utility::getMediaPlayers()
{
public:
Hkey( Hkey& hkey,const buffer& subKey ) :
m_status( this->open( hkey,subKey,hkey.regSam() ) )
m_regSam( hkey.regSam() ),
m_status( this->open( hkey,subKey ) )
{
}
Hkey() : m_status( this->open( HKEY_CLASSES_ROOT,nullptr ) )
Hkey( REGSAM r ) :
m_regSam( r ),
m_status( this->open( HKEY_CLASSES_ROOT,nullptr ) )
{
}
~Hkey()
Expand Down Expand Up @@ -475,38 +478,17 @@ std::vector< utility::PlayerOpts > utility::getMediaPlayers()
}
private:
LSTATUS open( HKEY hkey,const char * subKey )
{
REGSAM wow64 = KEY_READ | KEY_WOW64_64KEY ;
REGSAM wow32 = KEY_READ | KEY_WOW64_32KEY ;

auto st = this->open( hkey,subKey,wow64 ) ;

if( st == ERROR_SUCCESS ){

m_regSam = wow64 ;
}else{
st = this->open( hkey,subKey,wow32 ) ;

if( st == ERROR_SUCCESS ){

m_regSam = wow32 ;
}
}

return st ;
}
LSTATUS open( HKEY hkey,const char * subKey,REGSAM regSam )
{
DWORD x = 0 ;

return RegOpenKeyExA( hkey,subKey,x,regSam,&m_key ) ;
return RegOpenKeyExA( hkey,subKey,x,m_regSam,&m_key ) ;
}
REGSAM m_regSam ;
HKEY m_key = nullptr ;
LSTATUS m_status ;
REGSAM m_regSam ;
} ;

Hkey rootKey ;
Hkey rootKey( wow ) ;

if( !rootKey ){

Expand Down Expand Up @@ -553,6 +535,32 @@ std::vector< utility::PlayerOpts > utility::getMediaPlayers()
return s ;
}

static void _add_entry( std::vector< utility::PlayerOpts >& a,utility::PlayerOpts& b )
{
for( const auto& it : a ){

if( it.name == b.name ){

return ;
}
}

a.emplace_back( std::move( b ) ) ;
}

std::vector< utility::PlayerOpts > utility::getMediaPlayers()
{
auto a = _getMediaPlayers( KEY_READ | KEY_WOW64_64KEY ) ;
auto b = _getMediaPlayers( KEY_READ | KEY_WOW64_32KEY ) ;

for( auto& it : b ){

_add_entry( a,it ) ;
}

return a ;
}

#else

std::vector< utility::PlayerOpts > utility::getMediaPlayers()
Expand Down

0 comments on commit 31fd6be

Please sign in to comment.