KalDLL Pro: Customization

kaldll_6The functionality of the DLL grew and grew as more people asked for more features.

One of these features was a better uptime counter, since the function I was using was GetTickCount(), with 32 bits representing milliseconds, it was limited for 49.7 days before it would rollover back to the beginning again.

kaldll_7I found a value in the registry that was updated regularly and was used to store a 64 bit uptime, though it was documented as not reliable to use on all system.

This new uptime counter allowed up 585 million years to pass before a rollover, which for systems using Windows, was very doubtful would be able to achieve.

kaldll_13Eventually it was requested for KalDLL to also have the ability to output information about what is currently playing in Winamp.

So after a bit of research again, I found that using the Windows message system, I could retrieve information about the current song and artist being played in Winamp.

Simple C++ DLL for Visual Basic 6.0

For that past few month or so I have been learning to make DLLs to use with Visual Basic, and in the process learning C++. The benefits of using C++ over Visual Basic is that division and multiplication can be up to 28x faster than the default Visual Basic method.

So I decided to write up a tutorial for others to make their own Visual Basic DLLs. First of all you need to understand the type differences between Visual Basic and Visual C++. The following list has the Visual Basic variable types on the left, and their C++ variable type equivalents on the right.

Integer > short

Long > long

Single > float

Double > double

Byte > unsigned char

String > BSTR

A BStr is a special COM object, which starts with a 4 byte integer for the length, and ends with two terminal string characters. It should also be noted that C++ is case sensitive, so the variable types on the right are how they should be in C++.

Now to create the DLL, open up a copy of Microsoft Visual C++ and select “Win32 Dynamic Link Library” for a new project and call it “Example”. An “Empty Application” will do for what we’re making when the “AppWizard” pops up.

With this new project created, goto the Project menu and add a new file, we need a new source file, I called mine “Main.cpp” but anything will do. Fill the new source file with the following source code.

#include <windows.h>
long _stdcall Multiply( long A, long B )
	return A * B;
long _stdcall Divide( long A, long B )
	return A / B;
long _stdcall SumOf( long A, long B )
	return A + B;


We include the Windows header since we may want to use APIs and because the BSTR is defined in there. The “_stdcall” is used to tell the compiler we want the parameters of the function pushed onto the stack in left to right order.

Now add a new module definition file to the Visual C++ project, call it “Example.def“. This file will let the compiler know what functions we want available to external programs, so after LIBRARY we put the name of our DLL, and under the EXPORTS section we put our available functions, “Multiply”, “Divide” and “SumOf”.

LIBRARY "Example"


Finally in your Visual Basic project in the Form_Load() function, we can declare the functions within our DLL and make a call to them. Below shows can example of using the Multiply() function and then outputting it using a message box.

Private Declare Function Multiply Lib "Example" (ByVal A As Long, ByVal B As Long) As Long
Private Declare Function Divide Lib "Example" (ByVal A As Long, ByVal B As Long) As Long
Private Declare Function SumOf Lib "Example" (ByVal A As Long, ByVal B As Long) As Long
Private Sub Form_Load()
	Dim i As Long
	i = Multiply(2, 6)
	MsgBox i, vkOkOnly, App.Title
End Sub


If all goes correctly, a message box should appear with the value “12” shown.

That’s all for this tutorial, I hope you found it useful.

KalDLL Pro

kaldllpro_1Expanding on my idea of KalDLL, I began adding additional features to it. One of which was the ability to display system stats.

I found some code on the internet which would, using assembly, retrieve information about the CPU.

Further expanding my understand of using C++, I began using the CreateWindow() API to create buttons, lists and text boxes for input, and the WM_PAINT message for drawing images.

kaldll_14My first attempt at this gave the looked of a low memory system, unless I managed to change the font object being used.

With a slightly improved version, it was possible to create custom “/<command>” for mIRC that could be formatted to output specific information from one of the many libraries I had added to KalDLL.

KalDLL and the Away Beep

kaldll_9This origin of this DLL came from the Away Beep script I original wrote in mIRC.

It all started when I was on IRC I wanted to get someones attention, it was quite important at the time since they were my web host and they hadn’t payed their bill so my sites were down.

But despite efforts to get their attention, they were AFK, so I began work on a mIRC script that would play a few beeping sounds if a certain character string was typed.

kaldll_10The script became quite popular on the IRC channel and eventually spread to other channels and servers.

I eventually made if so that you activate the beep, you needed to send “@<username>” where “<username>” is the name of the person your trying to get the attention of. So for me, it was “@Kaluriel

There was a limitation to the script though, which was that it wasn’t asynchronous to mIRC so everything frozen until it had done.


And if multiple people had spammed it, you could be stuck and eventually disconnected from the server for not replying to a PING message.

So I began work on a plugin for mIRC that would multithread this process, and give better control over composing. So I began work on KalDLL.

I don’t have any images of the KalDLL version of away beep so I’ve substituted with the KalDLL Pro version, theres not much difference, I kept the same style during the port over.