ResFile

Environment: VC6, SP5
  • Warning Level 4.0 compliant
  • Documentation is doxygen compatible

ResFile is a nice project that allows reading from the resources of an ordinary DLL (or EXE) just as if it were a normal CFile. There are many useful scenarios. I used it to compile default INI files in my application, for example.

The class CResourceFile is derived from CFile and therefore may be used at any place where CFile could be used. Use it in conjunction with a CArchive to have buffered string reading capabilities.

Remember that, at the moment, only read-only access is implemented. Write access is theoretically also possible (via UpdateResource), but not yet implemented.

CResourceFile reads the complete file when opening it (this is the nature of Windows resource memory reading), keeping it in a buffer. Following Read() Operations are just returning from the buffer.

It is simple to use; just follow these points:

  • You can extract just the class (the two files, ResFile.cpp and ResFile.h, out of the sample project).
  • Just include a resource of type "BINARY" (use the quotation marks in Resource Editor).
  • Pass the constructor the module's own instance handle; for example, AfxGetApp()->m_hInst.
  • Call Open() and pass the resource name (use MAKEINTRESOURCE if you have only numerical IDs) and CFile::modeRead.
  • Then, call a read and you will have CFile-like access on your resources.

Downloads

Download source - 11 Kb


Comments

  • is not yet implement write func??

    Posted by pegas on 03/04/2004 09:11pm

    it's so cool idea.. not use registry or dummy file.. but,, i feel at a loss with-out Write func. is not yet implement??

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • The explosion in mobile devices and applications has generated a great deal of interest in APIs. Today's businesses are under increased pressure to make it easy to build apps, supply tools to help developers work more quickly, and deploy operational analytics so they can track users, developers, application performance, and more. Apigee Edge provides comprehensive API delivery tools and both operational and business-level analytics in an integrated platform. It is available as on-premise software or through …

  • Live Event Date: September 16, 2014 @ 11:00 a.m. ET / 8:00 a.m. PT Are you starting an on-premise-to-cloud data migration project? Have you thought about how much space you might need for your online platform or how to handle data that might be related to users who no longer exist? If these questions or any other concerns have been plaguing you about your migration project, check out this eSeminar. Join our speakers Betsy Bilhorn, VP, Product Management at Scribe, Mike Virnig, PowerSucess Manager and Michele …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds