Project

General

Profile

Scripting DLL » History » Version 14

Per Amundsen, 08/13/2014 07:25 AM

1 1 Per Amundsen
h1. Scripting DLL
2 2 Per Amundsen
3
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.
4
5 3 Per Amundsen
If you want to create a DLL for use with [[$dll]] [[$dllcall]] or [[/dll]] you need to create a specific routine like this in your DLL file.
6
7
*int __stdcall procname(HWND mWnd, HWND aWnd, char *data, char *parms, BOOL show, BOOL nopause)*
8
9 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.
10 3 Per Amundsen
11 10 Per Amundsen
_You may need to create a .def file with the "procname" names exported when compiling your DLL._
12 3 Per Amundsen
13
*Parameters*
14 5 Per Amundsen
15 3 Per Amundsen
mWnd - The handle to the main AdiIRC window.
16
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.
17
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.
18
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.
19
show - Is FALSE if the . prefix was specified to make the command quiet, or TRUE otherwise.
20
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.
21
22
*Returns*
23
24
The routine can return an integer to indicate what it wants AdiIRC to do:
25
26
0 - Means that AdiIRC should /halt processing.
27
1 - Means that AdiIRC should continue processing.
28
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.
29
3 - Means that the DLL has filled the data variable with the result that [[$dll]] as an identifier should return.
30
31
*Keeping a DLL Loaded after a call*
32
33
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:
34
35 14 Per Amundsen
*void __stdcall LoadDll(LOADINFO*);
36 1 Per Amundsen
37 3 Per Amundsen
 typedef struct {
38
   DWORD  mVersion;
39
   HWND   mHwnd;
40
   BOOL   mKeep;
41 1 Per Amundsen
   BOOL   mUnicode;
42 3 Per Amundsen
 } LOADINFO;
43 14 Per Amundsen
*
44 6 Per Amundsen
45
*Struct parameters*
46
47 3 Per Amundsen
mVersion - Contains the AdiIRC version number in the low and high words.
48
mHwnd - Contains the window handle to the main AdiIRC window.
49
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.
50
mUnicode - Indicates that text is in unicode as opposed to ansi.
51
52
*Unloading a DLL*
53
You can unload a loaded DLL by using the -u switch:
54
55
<pre>
56
/dll -u <filename>
57
</pre>
58
59
AdiIRC will automatically unload a DLL if it is not used for ten minutes, or when AdiIRC exits.
60
61
You can also define an UnloadDll() routine in your DLL which AdiIRC will call when unloading a DLL to allow it to clean up.
62 1 Per Amundsen
63
*int __stdcall UnloadDll(int mTimeout);*
64 6 Per Amundsen
65 3 Per Amundsen
mTimeout can be:
66 8 Per Amundsen
67 3 Per Amundsen
0 - UnloadDll() is being called due to a DLL being unloaded with [[/dll]] -u
68
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.
69
2 - UnloadDll() is being called due to a DLL being unloaded when AdiIRC exits.