examples/SysLibs/ResourceFiles/MultiRead1/MultiRead1.cpp

00001 // Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
00002 // All rights reserved.
00003 // This component and the accompanying materials are made available
00004 // under the terms of "Eclipse Public License v1.0"
00005 // which accompanies this distribution, and is available
00006 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
00007 //
00008 // Initial Contributors:
00009 // Nokia Corporation - initial contribution.
00010 //
00011 // Contributors:
00012 //
00013 // Description:
00014 // This example, together with MultiRead2, shows how to use multiple
00015 // resource files with cross-referenced resources.
00016 // It introduces the class CMultipleResourceFileReader, capable of
00017 // reading resources from multiple      resource files. However, only one
00018 // resource file is used. The example MultipleReader2 uses more than one resource file
00019 //
00020 
00021 
00022 
00023 #include "CommonToResourceFilesEx.h"
00024 
00025 #include <multiread1.rsg> // resources
00026 #include "MultiRead.h"
00027 
00028 // Do the example
00029 void doExampleL()
00030         {
00031         _LIT(KFormat,"%S\n");
00032 
00033         // allocate multi-reader
00034         CMultipleResourceFileReader* multiReader =
00035                         CMultipleResourceFileReader::NewLC();
00036 
00037         // open resource file on the emulator(__WINS__  is defined for the Windows emulator)
00038         // (leave if error)
00039         #if defined(__WINS__)
00040         // add MultipleReader1 version 23
00041         _LIT(KZSystemDataBasigbRsc,"Z:\\Resource\\apps\\MultiRead1.rsc");
00042 
00043         multiReader->AddResourceFileL(KZSystemDataBasigbRsc,23);
00044         #endif
00045 
00046         // open a resource file on the target phone
00047         // ( __EPOC32__ is defined for all target hardware platforms regardless of processor type/hardware architecture)
00048         #if defined(__EPOC32__)
00049         // add MultipleReader1 version 23
00050         _LIT(KCSystemDataBasigbRsc,"Z:\\Resource\\apps\\MultiRead1.rsc");
00051         multiReader->AddResourceFileL(KCSystemDataBasigbRsc,23);
00052         #endif
00053 
00054         // read string resource from file into a descriptor
00055         HBufC8* dataBuffer=multiReader->AllocReadLC(R_BASE_HELLO);
00056         TResourceReader reader;
00057         reader.SetBuffer(dataBuffer);
00058         TPtrC textdata = reader.ReadTPtrC();
00059 
00060         // write string to test console
00061         console->Printf(KFormat, &textdata);
00062         // clean up data buffer
00063         CleanupStack::PopAndDestroy(); // finished with dataBuffer
00064 
00065         // cleanup multi-reader
00066         CleanupStack::PopAndDestroy(); // multi-reader
00067         }
00068 

Generated by  doxygen 1.6.2