## MetaKit sample code - KitBinder

This application is a generic utility for the MetaKit library.

What it does: KitBinder is a utility program which converts any MetaKit datafile into a format suitable for embedding as resources inside an excutable program. The current version supports Win16 and Win32.

What it illustrates: KitBinder further enhances the stand-alone nature of MetaKit by allowing you to package read-only data as part of your application, to simplify deployment and installation. Compression is used to further reduce the size of this read-only data, the resources can optionally be encoded to protect sensitive data.

How to use it: To use these resources, you must make some very simple changes to your code, using the "c4_BoundStorage" class which is part of the KitBinder sample code.

Here is some more information from the "kbound.h" file:

> The process of switching to bound data is quite simple: Presumably, you have a MetaKit datafile with some data in it. Let's assume it is now stored in a file called "try.dat". Create source files for the resource editor (Win32): kbinder try.dat kbtry, or for Win16, use a text format instead: kbinder -t try.dat kbtry. This produces a file called "kbtry.rc", as well as one or more files called "kbtryXXX.res" (or "kbtryXXX.rc" if text format). Add the following line to your application resource file: #include "kbtry.rc" Include the file "kbound.h" to define the c4_BoundStorage class, and include the code which is in "kbound.cpp" in your project. Create your storage object from the class "c4_BoundStorage", ie. change: c4_Storage myStorage ("try.dat", false); to c4_BoundStorage myStorage; That's it, you now have a read-only copy of "try.dat" bound to your application and no longer need that data file at run time. Everything will continue to work, but you cannot commit changes. You can however call DumpAsRes, or c4_Storage::SaveToStream. For the original comments about the compression code, see "kboundw.cpp". To use encoding, you need to point c4_BoundStorage::_Encoder to an appropriate function before creating any instances of c4_BoundStorage.

The "kbdump" program is a example based on some code taken from the "Dump" utility. When you run it, it will dump a sample datafile (the catalog of the Metakit 1.5 release). That data was bound using the procedure described above, and is embedded in the "kbdump" executable.

Known problems: None.

Files in EXAMPLES\KN\BIND:

DUMP.CPP - Dump main program
DUMP.MAK, DUMP.MDP - MSVC 4.2 project makefiles for Win32

|| Roadmap Class Index Sample Index || Introduction Tips and Tricks ||