The Final Export
At this point you
can compile your DLL and everything should work. At this point you
could use it in VB, but the functions you exported are going to have
mangled names. If you installed the program Dependency Walker when
you installed Visual Studio you can open the newly compiled
vbgamerzip.dll to view its function exports. Depending on if C++
undecoration is turned on in the program, thefunction names will either
look like garbage or it will look like source code. The compiler
is renaming the exported functions so that it's paramater list is
encoded in the function name. This can be usefull, but not in our
situation. We already know our paramter list, so lets use the
function names we created earlier since VB doesn't support function
decoration. However, you could use the "Alias" paramter in VB when
defining the functions to name them whatever you want. You can
skip this step if you know what you're doing, but I wouldn't advise it.
If
the DLL doesn't compile at this point, then look at the errors and try
to correct the mistakes. You can opt to download the project files
for this tutorial and compare your code with mine.
Exports.def
Next, you'll need to add a text file to your project. From the "File" menu, select "New." Then select "
Text File" from the "Files" tab, but make sure the file name has a "
.def" extension.
I used the name "exports.def" for this project.
The
exports file is very simple. It is not C or C++ code. You
simply type the word "EXPORTS" and then the names of the functions that
we're exporting. This list is what prevents the compiler from
creating mangled function names. Here is what the file should look
like.
- EXPORTS
- VBCRC32
- VBZipOpen
- VBZipOpenNewFileInZip
- VBZipWriteFile
- VBZipCloseFile
- VBZipClose
- VBUnZipOpen
- VBUnZipClose
- VBUnZipGetGlobalInfo
- VBUnZipGetGlobalComment
- VBUnZipFirstFile
- VBUnZipNextFile
- VBUnZipGetFileInfo
- VBUnZipOpenFile
- VBUnZipOpenFileEx
- VBUnZipCloseFile
- VBUnZipReadFile