Пример #1
0
BOOL GetDriverSpecs( struct display_t *pEntry, char *szSubKey )
{
	HKEY hKey, hKey2;
	char *p;
	char szTemp[ MAX_PATH + 1 ] = "", szTemp2[ MAX_PATH + 1 ] = "";

	hKey = MyRegOpenKey( HKEY_LOCAL_MACHINE, "System\\CurrentControlSet\\Services\\Class" );
	if( hKey )
		hKey2 = MyRegOpenKey( hKey, szSubKey );
	else
		return FALSE;

	RegCloseKey( hKey );
	if( !hKey2 )
		return FALSE;

	if( !(p = MyRegQueryValueMalloc( hKey2, "DriverDesc", NULL, NULL ) ) )
		return FALSE;
	strcpy( pEntry->szName, p );
	free( p );

	hKey = MyRegOpenKey( hKey2, "DEFAULT" );
	if( !hKey )
		return FALSE;

	if( !(p = MyRegQueryValueMalloc( hKey, "drv", NULL, NULL ) ) )
		return FALSE;
	strcpy( pEntry->szDriver, p );

	// if no drive is specified in the driver filename, assume a path relative to the windows
	// system directory
	if( !strchr( p, ':' ) )
	{
		GetSystemDirectory( szTemp, MAX_PATH );
		strcat( szTemp, "\\" );
		strcat( szTemp, p );
	}
	else
		strcpy( szTemp, p );

	free( p );

	if( !GetMyFileVersionInfo( szTemp, pEntry ) )
		return FALSE;

	if( strlen( szTemp ) )
		SetCurrentDirectory( szTemp );

	RegCloseKey( hKey );
	RegCloseKey( hKey2 );

	return TRUE;
}
Пример #2
0
DWORD SearchAllSubkeysForDisplays( HKEY hKey, struct display_t *pDispEntry, DWORD nMaxInt, DWORD nFound )
{
	DWORD index = 0;
	HKEY hSubKey;
	char *name = NULL;
	char *data = NULL;

	if( !hKey )
		return nFound;

	if( !(nFound < nMaxInt) )
		return nFound;

	while( name = MyRegEnumKeyMalloc( hKey, index ) )
	{
		nFound = SearchAllSubkeysForDisplays( hSubKey = MyRegOpenKey( hKey, name ), pDispEntry, nMaxInt, nFound );
		if( hSubKey )
			data = MyRegQueryValueMalloc( hSubKey, "Class", NULL, NULL );
		if( data )
		{
			if( strnicmp( data, "Display", 8 ) == 0 )
			{
				free( data );
				data = MyRegQueryValueMalloc( hSubKey, "Driver", NULL, NULL );
				if( data )
				{
					if( nFound < nMaxInt )
					{
						if( GetDriverSpecs( (pDispEntry + nFound), data ) )
							nFound++;
						else
							ClearEntry( pDispEntry + nFound );
					}
					free( data );
				}
			}
		}
		if( hSubKey )
			RegCloseKey( hSubKey );
		free( name );
		index++;
	}

	return nFound;
}
Пример #3
0
char *MyRegQuickQueryMalloc( HKEY hKey, LPCSTR szSubKey, LPCSTR szValueName, LPDWORD pType, LPDWORD pSize )
{
	HKEY hNew;
	char *pData;

	if( !(hNew = MyRegOpenKey( hKey, szSubKey)) )
		return NULL;

	pData = MyRegQueryValueMalloc( hNew, szValueName, pType, pSize );

	RegCloseKey( hNew );
	return pData;
}