MindDial-Up Counter, Developer page
MindDial-Up Counter is an open project, in the sense you can write a viewer that performs various operations on the data automatically stored and shows it. My goal is to let you access the data with ease.
To build up a viewer you should:
- Create a DLL.
- Export 2 functions.
Index
A useful header
To ease the complications of creating a compliant DLL I've written a include file, which masks the passes needed to export your functions within some defines.
The file is Dll_Export_Type.h and I suggest you to look at it right now. It simply states that the call mode will be __stdcall. To let things roll you should define BUILD_DLL before including this unit, so the compiler will export functions properly.
To use the macros use (for example we want to export a function called MyFunc returning void):
#include "Dll_Export_Type.h"
DLLMETHOD(void) MyFunc(HINSTANCE hinst);
In the header file (called header.h) and
#define BUILD_DLL
#include "header.h"
DLLMETHODIMP(void) MyFunc(HINSTANCE hinst)
{
// some code...
}
in the main file (header.cpp).
That's all you need.
Index
Functions to export
You need to export only 2 functions:
- DLLMETHOD(void) ExecuteDLL();
- DLLMETHOD(LPCSTR) GetDLLDescs();
| Function name
| Description
| Return value
|
DLLMETHOD(LPCSTR) GetDLLDescs();
| This is the way to tell MindDial-Up Counter the name of the visualizer. It will be shown when the user switches to Visualizers in the pop-up menu. Also it's the preferred way that MindDial-Up Counter uses to understand if a DLL is a compatible visualizer or not.
| Returns a constant pointer to a null terminated string (only ANSI).
|
DLLMETHOD(LPCSTR) GetDLLDescs();
| MindDial-Up Counter calls this method only when the user selects this visualizer from the pop-up menu. This is the place where your visualizer must operate.
Do not use DllEntryPoint for this! As you might guess, MindDial-Up Counter loads and unloads your DLL dynamically, resulting in a constant flow of calls to this method. I suggest also that the code here is as fastest as possible (maybe save HINSTANCE for latter methods).
| Nothing. Maybe there will be (in future releases) other way to communicate with MindDial-Up Counter but, for now, your DLL should live independently from the main instance.
|
Now you're asking: how for the hell I retrieve the datas? let's move on it... :-)
Index
Handling datas 1: the data list
To handle the datas stored by MindDial-Up Counter you have a DLL at your service. It's called mdudata.dll and encapsulates the code needed to retrieve and operate with the datas. Although I ship the complete source code of this DLL you must not link it's code directly: this would break the future compatibility of your DLL. I promise that whenever I upgrade the DLL you will always have your one working correctly (that's what the DLL are for).
The DLL exports a very important class called MDUDataList. This class is the "container" of your data. This class extends _MDUPtrArray class (that you will never call directly).
Then with MDUDataList you have 2 methods:
| Function name
| Parameters
| Return value
| Description
|
MMDUDataList();
| None.
| None.
| Is the constructor, that takes no parameters. It will retrieve the data and set up itself. Just call it as you normally would with a constructor.
|
int GetCount() const;
| None.
| An integer.
| Returns the number of elements contained in this class. Use it to check for the upper bound of the array (the lowest is always 0).
|
LPCMMDUDATAELEMENT operator[](int iIndex) const;
| Integer indicating the position requested.
| A pointer to a constant MMDUDataElement.
| This function actually give you access to the data element, given an index. More on MMDUDataElement later.
|
Note that the class retrieves the data in the constructor so if you need fresh data you simply close down this object and spawn a new one.
Index
Handling datas 2: the data element
The data element (MDUDataElement) is a little bit more complex because it's written in a way that I can power it without messing with your code. So when you access a data element and it supports new features your code will work the same as before.
The key are the datas are in VOID type. The class of course will tell you what kind of data is stored in a specific position via a call to MDUE_TYPE GetTypeElement(int iIndex) const;. Then, when you request the data (with const LPVOID GetElementData(int iIndex) const;) you have to cast it to the appropriate type.
Currently you should expect:
- A null-terminated ANSI string.
- A
SYSTEMTIME (it's a Windows structure so check their help).
- A Double word (unused yet).
You can access a specific data using the enumeration MDUE_POS defined above the class itself. Right now I support this informations:
MDUEP_SZ_ENTRY_NAME: Connection type (as "America On-Line"). Always a string.
MDUEP_SZ_DEVICE_TYPE: Type of device used to connect (as "modem"). Always a string.
MDUEP_SZ_DEVICE_NAME: The name of the device (as "Diamond express"). Always a string.
MDUEP_START_TIME: The local time when the connection begun. Always SYSTEMTIME.
MDUEP_STOP_TIME: The local time when the connection ended. Always SYSTEMTIME.
MDUEP_USER_NAME: The name of the user who connected (Ie the one that logged-on). Always a string.
Let's formalize the functions:
| Function name
| Parameters
| Return value
| Description
|
int GetVersion() const;
| None.
| int describing the current version.
| Use for check for the version of the class a user has.
|
int GetElementsCount() const;
| None.
| An integer.
| Returns the number of elements contained in this class. Use it to check for the upper bound of the array (the lowest is always 0).
|
MDUE_TYPE GetTypeElement(MDUE_POS mdue) const;
| The position requested (defined in the MDUE_POS enumeration).
| An MDUE_TYPE.
| Returns the type of data stored in the given position (MDUE_TYPE is a enumeration defined in the top of the file, next to the defines).
|
const LPVOID GetElementData(MDUE_POS mdue) const;
| The position requested (defined in the MDUE_POS enumeration).
| A generic pointer to the data.
| Returns the data stored in the given position. Cast it to the type given by GetTypeElement(MDUE_POS).
|
So far so good... but let's see an example.
Index
A working example
Just follow this link...
Index
|