|
- Written and documented by David Deley
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12.1:
12.2:
12.3:
12.4:
Introduction to CMac Chapter 9: Calling user-written dll
Multi-Edit CMAC has the ability to call external user-written routines
that are in a Dynamic Link Library (DLL). You can write your code using
any language, such as C++. (I don't explain how to create a dll here.)
Add an import statement to your CMAC code, then you can call your external user-written routine.
Attached here is a simple example. The attached .zip file contains:
1. "testmydll.s" - CMAC macro which calls routine "set_all" in file "testdll.dll"
2. "testdll.dll" - Compiled Dynamic Link Library containing routine "set_all"
3. "testdll.cpp" - Source code for "testdll.dll"
4. "stdafx.h" - Another source file that was automatically
generated by my Microsoft Visual C++ 6.0 which does just about nothing
but I include it here for completeness.
5. "testdll.txt" - (This text)
INSTALLING "TESTDLL.DLL"
1. Exit Multi-Edit. This forces Multi-Edit to unload any previous "testdll.dll" file it might have loaded so you can replace it.
2. Copy the file "testdll.dll" to your Multi-Edit folder (e.g.
"C:\Program Files\Multi-Edit") replacing any previous version of
"testdll.dll"
3. Restart Multi-Edit. It will now load the new "testdll.dll" file when you first call it.
TESTING
1. Open "testmydll.s" in Multi-Edit.
2. Compile the code.
3. Run the "testall" macro.
String 'a' will be changed to "EFGH"
Integer i will be set to 8 (i = i + BUFLEN + 2) [BUFLEN being the second parameter passed in the call to set_all()].
See file "testdll.cpp" for the code.
Note how the second parameter, BUFLEN, is passed by value, and the
third parameter, i, is passed by reference (pointer). I did this just
to demonstrate the two ways. |