move floating globals into a namespace

This commit is contained in:
Chris Danford
2005-12-08 23:38:35 +00:00
parent 8c8c5c2dc7
commit 129381e4e9
4 changed files with 27 additions and 23 deletions
+11 -11
View File
@@ -91,24 +91,24 @@ static void GetDriveDebugInfo9x()
* DeviceDesc "GENERIC IDE DISK TYPE01" * DeviceDesc "GENERIC IDE DISK TYPE01"
*/ */
vector<CString> Drives; vector<CString> Drives;
if( !GetRegSubKeys( "HKEY_LOCAL_MACHINE\\Enum\\ESDI", Drives ) ) if( !RegistryAccess::GetRegSubKeys( "HKEY_LOCAL_MACHINE\\Enum\\ESDI", Drives ) )
return; return;
for( unsigned drive = 0; drive < Drives.size(); ++drive ) for( unsigned drive = 0; drive < Drives.size(); ++drive )
{ {
vector<CString> IDs; vector<CString> IDs;
if( !GetRegSubKeys( Drives[drive], IDs ) ) if( !RegistryAccess::GetRegSubKeys( Drives[drive], IDs ) )
continue; continue;
for( unsigned id = 0; id < IDs.size(); ++id ) for( unsigned id = 0; id < IDs.size(); ++id )
{ {
CString DeviceDesc; CString DeviceDesc;
GetRegValue( IDs[id], "DeviceDesc", DeviceDesc ); RegistryAccess::GetRegValue( IDs[id], "DeviceDesc", DeviceDesc );
TrimRight( DeviceDesc ); TrimRight( DeviceDesc );
int DMACurrentlyUsed = -1; int DMACurrentlyUsed = -1;
GetRegValue( IDs[id], "DMACurrentlyUsed", DMACurrentlyUsed ); RegistryAccess::GetRegValue( IDs[id], "DMACurrentlyUsed", DMACurrentlyUsed );
LOG->Info( "Drive: \"%s\" DMA: %s", LOG->Info( "Drive: \"%s\" DMA: %s",
DeviceDesc.c_str(), DMACurrentlyUsed? "yes":"NO" ); DeviceDesc.c_str(), DMACurrentlyUsed? "yes":"NO" );
@@ -130,37 +130,37 @@ static void GetDriveDebugInfoNT()
* Type "DiskPeripheral" * Type "DiskPeripheral"
*/ */
vector<CString> Ports; vector<CString> Ports;
if( !GetRegSubKeys( "HKEY_LOCAL_MACHINE\\HARDWARE\\DEVICEMAP\\Scsi", Ports ) ) if( !RegistryAccess::GetRegSubKeys( "HKEY_LOCAL_MACHINE\\HARDWARE\\DEVICEMAP\\Scsi", Ports ) )
return; return;
for( unsigned i = 0; i < Ports.size(); ++i ) for( unsigned i = 0; i < Ports.size(); ++i )
{ {
int DMAEnabled = -1; int DMAEnabled = -1;
GetRegValue( Ports[i], "DMAEnabled", DMAEnabled ); RegistryAccess::GetRegValue( Ports[i], "DMAEnabled", DMAEnabled );
CString Driver; CString Driver;
GetRegValue( Ports[i], "Driver", Driver ); RegistryAccess::GetRegValue( Ports[i], "Driver", Driver );
vector<CString> Busses; vector<CString> Busses;
if( !GetRegSubKeys( Ports[i], Busses, "Scsi Bus .*" ) ) if( !RegistryAccess::GetRegSubKeys( Ports[i], Busses, "Scsi Bus .*" ) )
continue; continue;
for( unsigned bus = 0; bus < Busses.size(); ++bus ) for( unsigned bus = 0; bus < Busses.size(); ++bus )
{ {
vector<CString> TargetIDs; vector<CString> TargetIDs;
if( !GetRegSubKeys( Busses[bus], TargetIDs, "Target Id .*" ) ) if( !RegistryAccess::GetRegSubKeys( Busses[bus], TargetIDs, "Target Id .*" ) )
continue; continue;
for( unsigned tid = 0; tid < TargetIDs.size(); ++tid ) for( unsigned tid = 0; tid < TargetIDs.size(); ++tid )
{ {
vector<CString> LUIDs; vector<CString> LUIDs;
if( !GetRegSubKeys( TargetIDs[tid], LUIDs, "Logical Unit Id .*" ) ) if( !RegistryAccess::GetRegSubKeys( TargetIDs[tid], LUIDs, "Logical Unit Id .*" ) )
continue; continue;
for( unsigned luid = 0; luid < LUIDs.size(); ++luid ) for( unsigned luid = 0; luid < LUIDs.size(); ++luid )
{ {
CString Identifier; CString Identifier;
GetRegValue( LUIDs[luid], "Identifier", Identifier ); RegistryAccess::GetRegValue( LUIDs[luid], "Identifier", Identifier );
TrimRight( Identifier ); TrimRight( Identifier );
LOG->Info( "Drive: \"%s\" Driver: %s DMA: %s", LOG->Info( "Drive: \"%s\" Driver: %s DMA: %s",
Identifier.c_str(), Driver.c_str(), DMAEnabled == 1? "yes":DMAEnabled == -1? "N/A":"NO" ); Identifier.c_str(), Driver.c_str(), DMAEnabled == 1? "yes":DMAEnabled == -1? "N/A":"NO" );
@@ -52,7 +52,7 @@ static HKEY OpenRegKey( const CString &sKey )
return hRetKey; return hRetKey;
} }
bool GetRegValue( const CString &sKey, const CString &sName, CString &sVal ) bool RegistryAccess::GetRegValue( const CString &sKey, const CString &sName, CString &sVal )
{ {
HKEY hKey = OpenRegKey( sKey ); HKEY hKey = OpenRegKey( sKey );
if( hKey == NULL ) if( hKey == NULL )
@@ -78,7 +78,7 @@ bool GetRegValue( const CString &sKey, const CString &sName, CString &sVal )
return true; return true;
} }
bool GetRegValue( const CString &sKey, CString sName, int &iVal ) bool RegistryAccess::GetRegValue( const CString &sKey, CString sName, int &iVal )
{ {
HKEY hKey = OpenRegKey( sKey ); HKEY hKey = OpenRegKey( sKey );
if( hKey == NULL ) if( hKey == NULL )
@@ -99,7 +99,7 @@ bool GetRegValue( const CString &sKey, CString sName, int &iVal )
return true; return true;
} }
bool GetRegSubKeys( const CString &sKey, vector<CString> &lst, const CString &regex, bool bReturnPathToo ) bool RegistryAccess::GetRegSubKeys( const CString &sKey, vector<CString> &lst, const CString &regex, bool bReturnPathToo )
{ {
HKEY hKey = OpenRegKey( sKey ); HKEY hKey = OpenRegKey( sKey );
if( hKey == NULL ) if( hKey == NULL )
@@ -3,9 +3,13 @@
#define REGISTRY_ACCESS_H #define REGISTRY_ACCESS_H
#include <windows.h> #include <windows.h>
namespace RegistryAccess
{
bool GetRegValue( const CString &key, const CString &sName, CString &val ); bool GetRegValue( const CString &key, const CString &sName, CString &val );
bool GetRegValue( const CString &key, CString sName, int &val ); bool GetRegValue( const CString &key, CString sName, int &val );
bool GetRegSubKeys( const CString &key, vector<CString> &lst, const CString &regex = ".*", bool bReturnPathToo = true ); bool GetRegSubKeys( const CString &key, vector<CString> &lst, const CString &regex = ".*", bool bReturnPathToo = true );
}
#endif #endif
@@ -76,7 +76,7 @@ bool GetVideoDriverInfo( int iCardno, VideoDriverInfo &info )
"HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\Class\\Display": "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\Class\\Display":
"HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E968-E325-11CE-BFC1-08002BE10318}"; "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E968-E325-11CE-BFC1-08002BE10318}";
GetRegSubKeys( sTopKey, lst, ".*", false ); RegistryAccess::GetRegSubKeys( sTopKey, lst, ".*", false );
for( int i=lst.size()-1; i >= 0; --i ) for( int i=lst.size()-1; i >= 0; --i )
{ {
@@ -101,17 +101,17 @@ bool GetVideoDriverInfo( int iCardno, VideoDriverInfo &info )
{ {
const CString sKey = lst[iCardno]; const CString sKey = lst[iCardno];
if( !GetRegValue( sKey, "DriverDesc", info.sDescription ) ) if( !RegistryAccess::GetRegValue( sKey, "DriverDesc", info.sDescription ) )
{ {
/* Remove this one from the list and ignore it, */ /* Remove this one from the list and ignore it, */
lst.erase( lst.begin()+iCardno ); lst.erase( lst.begin()+iCardno );
continue; continue;
} }
GetRegValue( sKey, "DriverDate", info.sDate ); RegistryAccess::GetRegValue( sKey, "DriverDate", info.sDate );
GetRegValue( sKey, "MatchingDeviceId", info.sDeviceID ); RegistryAccess::GetRegValue( sKey, "MatchingDeviceId", info.sDeviceID );
GetRegValue( sKey, "ProviderName", info.sProvider ); RegistryAccess::GetRegValue( sKey, "ProviderName", info.sProvider );
GetRegValue( sKey, bIsWin9x? "Ver":"DriverVersion", info.sVersion ); RegistryAccess::GetRegValue( sKey, bIsWin9x? "Ver":"DriverVersion", info.sVersion );
return true; return true;
} }