Project

General

Profile

Scripting DLL » History » Version 22

Per Amundsen, 09/29/2015 10:02 AM

1 20 Per Amundsen
{{>toc}}
2
3 19 Per Amundsen
h1. DLL Support
4 2 Per Amundsen
5
The [[/dll]], [[$dll]] and [[$dllcall]] features allow you to make calls to DLL's designed to work with AdiIRC. The main reason you would want to do this is that processing information in a DLL can be far faster than doing so in a script, so for intensive data processing a DLL would be more efficient.
6
7 17 Per Amundsen
If you want to create a DLL for use with AdiIRC you need to create a specific routine like this in your DLL file.
8 3 Per Amundsen
9 22 Per Amundsen
_For technical reasons, the DLL must be compiled for 64 bit on 64 bit versions of AdiIRC._
10 18 Per Amundsen
11 3 Per Amundsen
*int __stdcall procname(HWND mWnd, HWND aWnd, char *data, char *parms, BOOL show, BOOL nopause)*
12
13 9 Per Amundsen
"procname" is the name of the routine you will call from AdiIRC, you can create as many as you need and they can be named anything.
14 3 Per Amundsen
15
_You may need to create a .def file with the "procname" names exported when compiling your DLL._
16 1 Per Amundsen
17 20 Per Amundsen
h2. Parameters
18 5 Per Amundsen
19 3 Per Amundsen
mWnd - The handle to the main AdiIRC window.
20
aWnd - The handle of the window in which the command is being issued, this might not be the currently active window if the command is being called by a remote script.
21
data - The information that you wish to send to the DLL. On return, the DLL can fill this variable with the command it wants AdiIRC to perform if any.
22
parms - Can be filled by the DLL on return with parameters that it wants AdiIRC to use when performing the command that it returns in the data variable.
23
show - Is FALSE if the . prefix was specified to make the command quiet, or TRUE otherwise.
24 1 Per Amundsen
nopause - Is TRUE if AdiIRC is in a critical routine and the DLL must not do anything that pauses processing in AdiIRC, eg. the DLL should not pop up a dialog.
25 3 Per Amundsen
26 20 Per Amundsen
h2. Returns
27 3 Per Amundsen
28
The routine can return an integer to indicate what it wants AdiIRC to do:
29
30
0 - Means that AdiIRC should /halt processing.
31
1 - Means that AdiIRC should continue processing.
32 1 Per Amundsen
2 - Means that it has filled the data variable with a command which it wants AdiIRC to perform, and has filled parms with the parameters to use, if any, when performing the command.
33 3 Per Amundsen
3 - Means that the DLL has filled the data variable with the result that [[$dll]] as an identifier should return.
34
35 20 Per Amundsen
h2. Keeping a DLL Loaded after a call
36 3 Per Amundsen
37
By default a DLL is unloaded immediately after you make the [[/dll]], [[$dll]] or [[$dllcall]] call. You can keep a DLL loaded by including a LoadDll() routine in your DLL, which AdiIRC calls the first time you load the DLL:
38
39 16 Per Amundsen
*void __stdcall LoadDll(LOADINFO*);*
40 1 Per Amundsen
41 3 Per Amundsen
 typedef struct {
42
   DWORD  mVersion;
43
   HWND   mHwnd;
44 1 Per Amundsen
   BOOL   mKeep;
45
   BOOL   mUnicode;
46 16 Per Amundsen
 } LOADINFO;
47 6 Per Amundsen
48 20 Per Amundsen
h2. Struct parameters
49 3 Per Amundsen
50 1 Per Amundsen
mVersion - Contains the AdiIRC version number in the low and high words.
51 3 Per Amundsen
mHwnd - Contains the window handle to the main AdiIRC window.
52
mKeep - Set to TRUE by default, indicating that AdiIRC will keep the DLL loaded after the call. You can set mKeep to FALSE to make AdiiRC unload the DLL after the call.
53
mUnicode - Indicates that text is in unicode as opposed to ansi.
54
55 20 Per Amundsen
h2. Unloading a DLL
56 21 Per Amundsen
57 3 Per Amundsen
You can unload a loaded DLL by using the -u switch:
58
59
<pre>
60
/dll -u <filename>
61
</pre>
62
63
AdiIRC will automatically unload a DLL if it is not used for ten minutes, or when AdiIRC exits.
64
65
You can also define an UnloadDll() routine in your DLL which AdiIRC will call when unloading a DLL to allow it to clean up.
66 1 Per Amundsen
67
*int __stdcall UnloadDll(int mTimeout);*
68 6 Per Amundsen
69 3 Per Amundsen
mTimeout can be:
70 8 Per Amundsen
71 3 Per Amundsen
0 - UnloadDll() is being called due to a DLL being unloaded with [[/dll]] -u
72
1 - UnloadDll() is being called due to a DLL not being used for ten minutes. The UnloadDll() routine can return 0 to keep the DLL loaded, or 1 to allow it to be unloaded.
73
2 - UnloadDll() is being called due to a DLL being unloaded when AdiIRC exits.