mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
I have recently made a windows dll in VB with a help from a few people, tested this dll in a vb application, works perfectly.

I am not a VB guru, nor a mIRC guru, thats why I need someones help, someone who is fairly good with vb/mIRC?

I try to test this dll in mIRC using something like:

//echo -a $dll(MathLib.dll,Square,2) which should echo 4, but instead it crashes mIRC and displays this error:


Firstly, any ideas whats causing that?
Secondly, I am willing to show the VB dll source to anyone if they are interested in helping me.

Thanks in advance.

Please don't cross post

Last edited by Mentality; 02/10/05 09:53 PM.
Joined: Apr 2003
Posts: 701
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Apr 2003
Posts: 701
Compile the dll without debug options and try that. Seems like the error is that mIRC cannot handle the debug information added to the dll.

Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
Thanks for the reply, I dont think the dll was made with the debug stuff anyway. In Vb, I clicked on Project->Project1 properties, selected the Debugging tab, and its all disabled anyway.

Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
this is the dll source with the Square function..

Code:
Option Explicit

Public Const DLL_PROCESS_DETACH = 0
Public Const DLL_PROCESS_ATTACH = 1
Public Const DLL_THREAD_ATTACH = 2
Public Const DLL_THREAD_DETACH = 3

Public Function DllMain(ByVal hInst As Long, ByVal fdwReason As Long, lpvReserved As Long) As Long
   Select Case fdwReason
      Case DLL_PROCESS_DETACH
         ' No per-process cleanup needed
      Case DLL_PROCESS_ATTACH
         DllMain = True
      Case DLL_THREAD_ATTACH
         ' No per-thread initialization needed
      Case DLL_THREAD_DETACH
         ' No per-thread cleanup needed
   End Select
End Function

Sub Main()
End Sub

Public Function Square(var As Long) As Long
   If Not IsNumeric(var) Then Err.Raise 5

   Square = var ^ 2
End Function


It works from test application in vb, but I really want to get this working with mIRC too

Last edited by pouncer; 02/10/05 10:08 PM.
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
1. VB6 is not capable of making win32 dlls, so you'll have to use a different language or settle for a COM object (.ocx).

2. As /help DLL support explains, all exported procedures within the dll that you want to call from mIRC need certain arguments:

Code:
The routine in the DLL being called must be of the form:

int __stdcall procname(HWND mWnd, HWND aWnd, char *data, char *parms, BOOL show, BOOL nopause)

Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
It is possible to make win32 dlls with a bit of wrapper coding, this is my exports file:

Quote:

LIBRARY MathLib

EXPORTS
Increment @2
Decrement @3
Square @4


and i also did try to put the function as

Code:
Public Function Square(ByVal mWnd as Long, ByVal aWnd as Long, ByVal strdata as String, _
ByVal parms As String, ByVal show as Long, ByVal nopause as Long) as Long


which still made mirc crash and stop the square function from wokring in a vb application

this is what i followed to make the win32 dll

http://www.windowsdevcenter.com/pub/a/windows/2005/04/26/create_dll.html?page=1

Last edited by pouncer; 02/10/05 11:09 PM.
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
Ah I see. Well my guess would be that you'll get the same answer from even the most advanced VB programmers since most people use a language that fits their needs out of the box.


Link Copied to Clipboard