To get started, open your Visual Studio
for use with VC++. As depicted below, we'll start by clicking
  1. File
  2. New
  3. Project...
  
 
 
Step 2.
Now lets move  on to naming our project and defining the project type. 
  1. Select Win32
  2. Win32 Project
  3. Name of Project (this will result in easydll.dll)
  4. OK  
 
Step 3.
 
I know this is kind of redundant but I didnt want a premature
'Finish', so just click the 'Next' button.
 
 
 
 
 Step 4. 
  1. DLL
  2. Empty Project
  3. Finish
 
Step 5.
 
This is what you should end up with.
A nice empty project.
 
Step 6.
  1. Right click "Source Files"
  2. Add
  3. New Item...
 
 
 
Step 7.
 
  1. Select "Visual C++"
  2. C++ File (.cpp)
  3. Name of project source file (could be anything)
  4. Add
 
 
Step 8.
  1. Right click "Source Files"
  2. Add
  3. New Item...
 
 
Step 9.
  1. Select "Visual C++"
  2. Text File (.txt)
  3. Name of your file that contains a list of your dll functions (could be anything)
  4. Add
Step 10.
 
  1. Select source file 'easydllsrc.cpp'
  2. Type the header, #include <windows.h>
 
 
Step 11.
I could just give you the 'main' call function, but I want to teach
everyone how to find this for their future reference. In mIRC
 type /Help or locate on file menu. Search for "DLL support" scroll
down to "technical notes"  and locate the routine...
 
int __stdcall procname(HWND mWnd,HWND aWnd, char *data, char *parms, BOOL show, BOOL nopause)
 
Well done, now copy.
 
 
 
Step 12.
  1. Select source file 'easydllsrc.cpp'
  2. Paste
  3. The routine appears
 
Step 13.
 
While still in 'easydllsrc.cpp' ...
 
  1. Change 'procname' to the function name you want. In my case  "funk1"
  2. Add left bracket to the routine
  3. Add right bracket  to the routine
  4. Insert strcpy, sets the variable data="data"
  5. Insert return 3; Sends it to mIRC.
 
 
 
Step 14.
 
  1. Select exports.def
  2. Type Library "easydllsrc" this must be your source file name.
  3. Type EXPORTS
  4. Type funk1 @ 1
We use LIBRARY "easydllsrc" to link our function name list
to our source file. simple enough.
The    funk1 @ 1
lets mIRC know the function exists and
that its the 1st function in the list.
 
 
Step 15.
 
The coding is complete, however we still have some
options to check over to ensure its success.
 
  1. Right click 'easydll' project name.
  2. Properties
 
 
 Step 16.
 
I think this is where people get lost, or maybe just me not used to
the snazzy interface.
 
  1. Select C/C++
  2. Precompiled Headers
  3. Create/Use Precompiled header  = Not using precompiled headers
This messed me up alot, if you use precompiled headers, it'll require stdafx.h
and you can even get it to work like this.. but if I understand it right, its unnecessary
unless you have repitious compilng and may give you more of a headache having it
enabled.
 
 
 
Step 17.
 
  1. Select Linker
  2. Select "Module Defenition File"
  3. Add .\exports.def
  4. OK
This was another headache that maybe others have, apparently
even though you did an Add, it might not associate it with your
project... maybe I did something differently, I dont know but it
was this that kept making mIRC say * $dll: no such routine 'function'
It wasnt until I did this step that it was abole to find my routines.
 
 
Step 18.
 
Finally, this step is optional... until you start having problems, then check
over this. 
  1. C/c++
  2. Command-Line
  3. Options
This is so you can check over your compiler options and find a setting
that could be jamming up your works. It doesnt have to look exactly like
this but if you have trouble, i'd try to get it as close as possible. 
 
 
 
Step 19.
 
  1. Linker
  2. Command-Line
  3. Options
The same deal applies,
 
Step 20.
 
You should be able to compile by now, so go ahead and Build your solution.
 
I include this only as a matter of efficiency and to show you how a DLL might
look if you have multiple functions.
 
As you can see, the std_calling  can be duplicated and only the function name changes.
  1. Select 'easydllsrc.cpp'
  2. duplicate function
  3. rename new function
 
 
 Step 21.
This is a typical build output, its not the pretiest compile as
you should probably change strcpy to strcpy_b or whatever, but
its easy enough to figure out on your own. Hopefully this should just
get you started.
 
 
 
Step 22.
 
I mentioned the matter of efficiency, I took the #define part from another tuorial, basically
this just makes a macro called MircWire, so your functions don't "appear" more complex.
 
  1.     Select 'easydllsrc.cpp'
  1.5  #define MircWire(x)
  2.     change function to x
  3     modify funk1 to MircWire(funk1)
  4     modify funk2 to MircWire(funk2)
 
 
 
Step 23.
 
As you've done before, 
 
  1. Add funk2 @ 2
  2. Rebuild Solution 
 
With any luck you're churning out DLLs in mIRC by now,
to access your accomplishments simply //echo -a : $dll(path:\easydll.dll,funk1,a)
The path can be your VC++ Debug/Release directory, or you can copy it to your mIRC
folder and avoid the path all together. For ease, you can  copy
this here...  //echo -a :: $dll($sfile(c:\),funk1,a)
The "a"  parameter is actually being passed to your DLL but
because we're not listening for it, nothing is done with it.
 
Step 24.
There is also another way to create a DLL function, avoiding using a .DEF file all together.
so after you have a clean solution setup with your windows.h header included you can try the
following:
extern "C" __declspec (dllexport) int __stdcall memmo (HWND mWnd, HWND aWnd, char *data,
char *parms, BOOL show, BOOL nopause) {
strcpy(data,"data");
return 3;
}
Its the same as what we had before, except in front of our _stdcall we put extern "C"
this changes the naming convention of our function to that of "C" and not C++ which
would come out distorted. The __declspec (dllexport) is what brings out our function name.
As you can see in the image, I have used a program called "DLL Export Viewer", its been really
handy telling me what the function looks like.. and after a compile, if I refresh and its not there
I can tell that the export was unsuccessful and i must be doing something wrong.
You can download from here:
http://www.nirsoft.net/utils/dll_export_viewer.html
In the export viewer you will notice it says _memmo@24 , This is how you will have to refer to it
in mIRC, rather than just by its plain routine name. Thats kind of the cost you have to pay for not
making a defenition file, but personally I wouldnt mind skipping a few steps in VC++ only to add
something like $+(_,name,@24) for mIRC. So do whats right for you.
The reason why its like this is explained in http://wyw.dcweb.cn/stdcall.htm (great tutorial btw), its
basically just a naming convention for stdcall which is what mIRC uses. I tried to use _cdecl but mIRC
kept crashing with it.
I personally like this method better, because of how little code you have to insert, and you won't have
to muck with the .def file. Note: if you do delete your .def file, you will have to go into the properties
again and delete the .\exports.def you had inserted. For some reason Visual Studio is not dealing with
the export files automatically, so keep that in mind.
This concludes Making a DLL for mIRC with Visual Studio 8.
by Chris Warren
 
Feel free to link to this tutorial, but please.. no ripping.