dapfTest - sample code to call DinkeyAdd Module in C#
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This project is written in Visual Studio 2002 but will work in more recent
versions of Visual Studio (they will upgrade the Project to the latest version.
If prompted you should also upgrade the .NET framework the project requires).
For users of Visual Studio 2005 or higher, the default setting to projects is to
compile for the Target Platform "Any". This means that on 32-bit Windows, your
code will run as 32-bit code (and needs to call DinkeyAdd32.dll) and under 64-bit
Windows your code will run as 64-bit code (and needs to call DinkeyAdd64.dll).
The sample code works this out automatically. If you select the target platform as "x86"
then it will always be 32-bit and so you only need to use DinkeyAdd32.dll. If you
select "x64" then your code will be 64-bit and you only need to use DinkeyAdd64.dll.
The main source files in the project are:
dapf.cs - the source file contains declarations of our API. We automatically
work out whether your code is running in 32-bit or 64-bit and load
the appropriate DinkeyAdd module.
Form1.cs - this is the sample code giving an example on how you can call our API.
It contains 5 functions. Just use which ever functions are most appropriate
and customise in your own way.
The best approach is to compile the sample code and see how it works and then to take
the appropriate code and apply it to your own project. You should include the dapf.cs
file in your project and use/modify which ever functions from Form1.cs you feel are
appropriate. The dapf.cs file should not be modified.
The sample code is just a guide. As none of the parameters are security sensitive then
there is no need to implement strong security in calling DinkeyAdd.
Make sure you remember to do the following when creating your own project:
1) Insert the following namespaces in your code file:
using System.Runtime.InteropServices;
2) Insert the dapf.cs file in your project.
3) You need to put DinkeyAdd32.dll and/or DinkeyAdd64.dll into the folder that
contains dapfTest. Otherwise the System.DllNotFoundException error will appear
when you run dapfTest.
Notes on Debugging 64-bit Code
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When you use the 64-bit module (DinkeyAdd64.dll) the anti-debug code is so strong
that if you are debugging your code, after calling our API then it will crash with
an SEH exception. There are no debug modules for DinkeyAdd so you will have to find
other ways of debugging your code (for example taking out the call altogether).