62 lines
3.6 KiB
Plaintext
62 lines
3.6 KiB
Plaintext
ChangeTest - sample code to call DinkeyChange.dll (DinkeyChange64.dll) in VB.NET
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
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.vb - 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.vb - 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.vb
|
|
file in your project and use/modify which ever functions from Form1.vb you feel are
|
|
appropriate. The DinkeyChange.vb 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.vb 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 message "Unable to open DLL (DinkeyChange.dll)" or
|
|
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 name in the DinkeyChange.vb 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.vb. This is an example for
|
|
DCDoUpdateCodeFromFile64:
|
|
|
|
#if DEBUG ' debug module
|
|
Declare Ansi Function DCDoUpdateCodeFromFile64 Lib "DinkeyChange64Debug.dll" Alias "DCDoUpdateCodeFromFile" _
|
|
(ByVal filename As String, ByRef confirmation_code As Integer, ByRef extended_error As Integer) As Integer
|
|
#else ' standard module
|
|
Declare Ansi Function DCDoUpdateCodeFromFile64 Lib "DinkeyChange64.dll" Alias "DCDoUpdateCodeFromFile" _
|
|
(ByVal filename As String, ByRef confirmation_code As Integer, ByRef extended_error As Integer) As Integer
|
|
#endif
|