65 lines
3.5 KiB
Plaintext
65 lines
3.5 KiB
Plaintext
ChangeTest - sample code to call DinkeyChange Module in C#
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
This project is written in Visual Studio 2003 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 DinkeyChange.dll) and under 64-bit Windows your code will
|
|
run as 64-bit code (and needs to call DinkeyChange64.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 DinkeyChange.dll. If you select "x64" then your code will be
|
|
64-bit and you only need to use DinkeyChange64.dll.
|
|
|
|
The main source files in the project are:
|
|
|
|
DinkeyChange.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 DinkeyChange module.
|
|
|
|
Form1.cs - this is the sample code giving an example on how you can call our API.
|
|
It contains 7 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 DinkeyChange.cs
|
|
file in your project and use/modify which ever functions from Form1.cs you feel are
|
|
appropriate. The DinkeyChange.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 DinkeyChange.
|
|
|
|
Make sure you remember to do the following when creating your own project:
|
|
|
|
1) Insert the DinkeyChange.cs file in your project.
|
|
|
|
2) You need to put DinkeyChange.dll and/or DinkeyChange64.dll into the folder that
|
|
contains your EXE file. Otherwise the System.DllNotFoundException error will appear
|
|
when you run ChangeTest.
|
|
|
|
You can rename DinkeyChange.dll (DinkeyChange64.dll) to a name of your choice. In this
|
|
case you will need to modify the dll names specified in the DinkeyChange.cs file.
|
|
|
|
Notes on Debugging 64-bit Code
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
When you use the 64-bit module (DinkeyChange64.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. If you want to be able to debug your code then you can setup your project so
|
|
that your code calls the debug module (DinkeyChange64Debug.dll) in your "debug" build and
|
|
the standard module (DinkeyChange64.dll) in your release build. In this case you will
|
|
need to modify the declarations of our API in DinkeyChange.cs. This is an example for
|
|
DCDoUpdateCodeFromFile64:
|
|
|
|
class DCDoUpdateCodeFromFile64
|
|
{
|
|
#if DEBUG ' debug module
|
|
[DllImport("DinkeyChange64Debug.dll", CharSet = CharSet.Ansi)]
|
|
public static extern int DCDoUpdateCodeFromFile(string update_code_file, out int confirmation_code, out int extended_error);
|
|
#else ' standard module
|
|
[DllImport("DinkeyChange64.dll", CharSet = CharSet.Ansi)]
|
|
public static extern int DCDoUpdateCodeFromFile(string update_code_file, out int confirmation_code, out int extended_error);
|
|
#endif
|
|
}
|