Just a followup to Dmitry's advice which is - as usual - accurate.

Caching is the most important key. You can organize your own cache or use the 
system cache - the code is bellow.

---------------------------------------------
#define dmMaxVersionStrLength   16

typedef struct tagLaunchCacheRecord
{
        UInt32  dbType ;
        UInt32  dbCreator ;
        UInt32  id ;
        UInt16  cardNo ;
        UInt16  attr ;
        UInt16  version ;
        char    name[dmDBNameLength] ;
        short   largeIconOffset ;
        short   smallIconOffset ;
        char    applName[dmDBNameLength] ;
        char    versionStr[dmMaxVersionStrLength] ;
        UInt8   flags;
}
LauncherCacheRecord ;

g_launchDB = 
        - usually "psysLaunchDB"
        - "HomeLaunchDB" in case of Zodiac (g_bLauncherNative=TRUE)

MemHandle recH ;
LauncherCacheRecord* recHdr ;

// Search the launcher database
for( i=0; i<recCnt; i++ )
{
        recH = DmQueryRecord(g_launchDB, i) ;
        if( recH != NULL )
        {
                recHdr = (LauncherCacheRecord*)MemHandleLock(recH) ;
                
                if( recHdr->dbCreator == expectedHdrCreatorID )
                {
                        hdrIconOffset = bSmall ? recHdr->smallIconOffset : 
recHdr->largeIconOffset ;
                        if( hdrIconOffset != NULL )
                        {
                                BitmapPtr bmp ;
                                if( g_bLauncherNative )
                                        swap16(&hdrIconOffset) ;

                                bmp = (BitmapPtr)(((char*)recHdr) + 
hdrIconOffset ) ;

                                if( (((UInt32)bmp)&3) == 0 )
                                {
                                        // you have the bitmap
                                        // Test on bmp!=NULL probably solves 
(occasional) problem of empty icons after Hotsync.
                                }
                        }
                        MemHandleUnlock( recH ) ;
                        break ;
                }
                MemHandleUnlock( recH ) ;
        }
}

---------------------------------------------

Run Resco Explorer (Applications tab) to see the performance of the icon 
caching. 

Take into account that Explorer does a lot more to speed up the cache. It 
internally organizes access tables for LRU icons and for creatorID's with no 
existing icon plus another cache for items not found in the system cache. 
However, as long as you use only RAM apps icons, you won't need these fancy 
things.

Regards,
  Jan Slodicka, Resco

-- 
For information on using the ACCESS Developer Forums, or to unsubscribe, please 
see http://www.access-company.com/developers/forums/

Reply via email to