Finishing The DLL
The
final step is to build the DLL. On the "Build" menu,
select "Build". Make sure you have "Win32 Release" selected
as the build type. There isn't any reason to use a Debug version
of the DLL in VB.
If you have any errors, then download the
source code that I provided. You can compare your version to mine,
or simply use my wrapper code as a starting point.
Summary
This
tutorial should have demonstrated how to create a DLL and export VB
compatible functions. The first step is to actually create a skeleton
DLL project, then to populate it with functions defined with
__declspec(dllexport) WINAPI, then to finally to create a .def file to export non-mangled function names.
Improvement And Extension
With
the zlib library you can compress and decompress binary streams
of data. To gain this functionality, you can export the compress
(or compress2) and uncompress functions. Such functions could be
used to create your own file format or to compress and decompress data
sent over a TCP/IP connection. If you're creating an
online game, you may want to consider compressing data before sending it.
You
can also use the techniques shown in this tutorial to create your own
functions in a C/C++ DLL to create accelerated functions to use within
VB. Instead of creating seperate DLLs, you can easily add your
functions to the zip DLL to make it easier to update.
References
zlib Home Site (
http://www.gzip.org/zlib/)