Project

General

Profile

Scripting DLL » History » Version 24

Per Amundsen, 10/04/2020 05:40 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 24 Per Amundsen
   DWORD  mBeta; 
47
   DWORD  dBytes;
48 16 Per Amundsen
 } LOADINFO;
49 6 Per Amundsen
50 20 Per Amundsen
h2. Struct parameters
51 3 Per Amundsen
52 1 Per Amundsen
mVersion - Contains the AdiIRC version number in the low and high words.
53 3 Per Amundsen
mHwnd - Contains the window handle to the main AdiIRC window.
54
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.
55
mUnicode - Indicates that text is in unicode as opposed to ansi.
56 1 Per Amundsen
mBeta - Contains the AdiIRC beta version number, for public beta releases.
57 24 Per Amundsen
dBytes - Maximum byte size for the mData parameter.
58 3 Per Amundsen
59 20 Per Amundsen
h2. Unloading a DLL
60 21 Per Amundsen
61 3 Per Amundsen
You can unload a loaded DLL by using the -u switch:
62
63
<pre>
64
/dll -u <filename>
65
</pre>
66
67
AdiIRC will automatically unload a DLL if it is not used for ten minutes, or when AdiIRC exits.
68
69
You can also define an UnloadDll() routine in your DLL which AdiIRC will call when unloading a DLL to allow it to clean up.
70 1 Per Amundsen
71
*int __stdcall UnloadDll(int mTimeout);*
72 6 Per Amundsen
73 3 Per Amundsen
mTimeout can be:
74 8 Per Amundsen
75 3 Per Amundsen
0 - UnloadDll() is being called due to a DLL being unloaded with [[/dll]] -u
76
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.
77
2 - UnloadDll() is being called due to a DLL being unloaded when AdiIRC exits.