IMG Developer's Kit: Developer's Kit Guide and Technical Documentation; Version 1.90; User's Guide | ||
---|---|---|
Prev | Chapter 8. Developer Tools and Examples | Next |
FOLDER: ADDONDLL
TYPE: External Capabilities for My-T-Soft
SOURCE: INCLUDED
LANGUAGE: C / Windows API
IDE: Microsoft Visual C++ 6
Overview:
The Add-On DLL capability provides the mechanism for an external DLL to integrate tightly with My-T-Soft, allowing various add-ons to operate in conjunction with the keyboard executable program during run-time. This is a fairly advanced topic, and the examples provided gives the developer all they need to use this effectively.
Examples:
- Communicating with another process in the system (through a shared DLL)
- Setting and Removing a system hook during the run of My-T-Soft
- Monitoring My-T-Soft for Developer Kit manipulation during its run via a DLL (rather than another process in the system)
- Logging Start/End/Run times of My-T-Soft
- Integrating with an Application to handle whether My-T-Soft is available or not
There are 3 integration options, with 9 different parameter options:
- Initialization (Startup)
- Run Time (System Timer controlled)
- Termination (Cleanup)
To enable this capability, the INI (MYTSOFT.INI/MYTTOUCH.INI//MYTPEN.INI) must be updated to include the relevant information (see below for further details).
Conceptually, this is how this works:
When the My-T-Soft executable begins, it reads the INI & if these [AddOnDLL?] section entries are correct, it will load the library, obtain the function address & call the function at the appropriate time (at init, via timer, or at termination). The DLL MUST be written in C, and have proper exports, handle the parameters correctly, etc. This isn't meant to be fancy or complicated it is done as straightforwardly as possible.
This is a My-T-Soft Developer's Kit example file for Windows, written in C. The project is in the ADDONDLL folder, created in Microsoft Visual C Version 6. For best results, play with the ADDONDLL.EXE & the INI first to understand how this works, then refer to the LOGDLL to see another example.
The example provided in the ADDONDLL folder is purely a template and an example of how to do the actual integration it only shows what is possible, it does not actually accomplish anything useful. You can refer to the LOGDLL example for a simple logging integration example.
To integrate and see the example, you need to update the INI file with the [AddonDLL1] section below, then run ADDONDLL.EXE to see how this works.
The following is an excerpt from the ADDONDLL.EXE Window display:
This window is simply a container to show the results of DLL calls to the ADDONDLL.DLL code, when integrated with the AddOnDLL entries in the .INI file.
This is a fairly advanced aspect of the software, and the developer should be familiar with DLLs and calling them dynamically using LoadLibrary and GetProcAddress Windows API calls. Furthermore, this approach presupposes a complex task that requires the use of a DLL to begin with (rather than externally from an application, or using other Developer Kit approaches).
This example was created to test the various options and ensure proper operation of the Initialization, Cleanup, and Timer based function calls. For a particular application of this approach, the unused functions can be removed if desired.
The following is an example entry from the .INI file to illustrate the use of this DLL. In the example, the InitFuncType7 function in the DLL will be called with the Value1 entry at Initialization of My-T-Soft, then during the run of My-T-Soft, the TimerFuncType9 in the DLL (with all supported parameters) will be called every second (1000 ms), and when My-T-Soft is closed, CleanupFuncType8 in the DLL will be called with the 3 value entries.
[AddOnDLL1]
DLLName=%PRODDIR%ADDONDLL\ADDON.dll
InitializeFunctionName=InitFuncType7
InitializeFunctionType=7
TimerFunctionName=TimerFuncType9
TimerFunctionType=9
TimerDelay=1000
CleanupFunctionName=CleanupFuncType8
CleanupFunctionType=8
Value1=1
Value2=201
Value3=3302
Notes:
There are 3 sections available - [AddOnDLL1], [AddOnDLL2], [AddOnDLL3]. Each section can have the Init, Timer, and/or Cleanup functions specified independently. By default, the FreeLibrary will be called at Cleanup, whether or not there is a Cleanup function specified. The [Type]FunctionName entries are ANSI (1 Byte Characters), and expect to be loaded in a C based DLL. A C++ DLL must export the function names as C (e.g. extern "C"), so any name mangling from C++ compilers does not change the actual exported name of the function. The 9 function types cover various aspects and address various needs. Most are of a C Declaration type (default "cdecl" assumed), but the WINAPI entries (similar to a CALLBACK entry) resolves to a FAR PASCAL, so these must carry the same type of declaration if built in another DLL. It is best to start with the declarations, or even start with the ADDON.C file, and strip out / rename pieces as desired, being sure to keep the rest of the declarations and definitions intact.
The TimerDelay entry is in milliseconds, and is used in a call to the Windows API SetTimer internally if there is a non-0 value for TimerDelay, TimerFunctionType, and some text in TimerFunctionName.
Error checking is basic, and error conditions are not reported. If the DLL is not loaded, or the function name not found, My-T-Soft will continue normally, but never call the DLL function.
When integrating an external DLL using this mechanism, verify path, file name, and function name entries carefully. You may want to verify your DLL function is being called, before implementing any real functionality in the DLL function.
If memory errors occur, verify the calling conventions, and verify you are not returning values for void functions, or different types than specified for the pre-defined function types.
Version 1.78 - August 9, 2005
Copyright © 2004-2005 by Innovation Management Group, Inc. All Rights Reserved.
My-T-Mouse, My-T-Pen, My-T-Touch, and My-T-Soft are registered trademarks of Innovation Management Group, Inc.
As seen in ...