mIRC Home    About    Download    Register    News    Help

Print Thread
Calling a (non-standard?) dll from mirc #124704 10/07/05 01:05 AM
Joined: Jul 2005
Posts: 2
S
Setter Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
S
Joined: Jul 2005
Posts: 2
I have a dll written in Delphi which has a form inside. The code to show the form is:
procedure show;stdcall;
begin
frmDLL := TfrmDLL.Create(nil);
frmDLL.Show;
end;

exports
show;

This works fine if I call "show" from a Delphi-compiled test program. But when I try to do /dll testDLL.dll show from mIRC, the form is shown, and mirc immediately crashes with "Memory cannot be read".

Anyone has any ideas how to fix it?

Re: Calling a (non-standard?) dll from mirc #124705 10/07/05 06:43 AM
A
Anonymous
Unregistered
Anonymous
Unregistered
A
It is of my understanding that in order for mIRC to interface properly with a DLL through the scripting, that the dll has to have a few things. Firstly, it has to have functions that have certain parameters, and secondly, it needs the standard function startup stuff. I use C/c++, not DELPHI, so hopefully this is of some help.

Here is the function header for a procedure that mIRC calls in one of the DLLs I wrong:
int __stdcall GetSong(HWND mWnd, HWND aWnd, char *Data, char *Parms, BOOL Show, BOOL NoPause);

Here is the procedure header I use to start up the DLL, when DLLs are attached to a process in windows, this is always called:
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)

I dunno if this is all that much help to you, but below is a link to the MSDN information on DllMain entry points in DLLs.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/dllmain.asp

I can't remember exactly how you keep DLLs loaded, I don't think I ever wrote one that needed that.

Anyways, it's been a long time since I've done any work with DLLs, and if you would like the sourcecode to that simple Winamp song grabber, send me a private message via this board with your email address, and I'll ship it out to ya ASAP.

Re: Calling a (non-standard?) dll from mirc #124706 10/07/05 12:36 PM
Joined: Nov 2003
Posts: 2,327
T
tidy_trax Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
Most of the info you need to know is in /help dll support


New username: hixxy
Re: Calling a (non-standard?) dll from mirc #124707 10/07/05 02:11 PM
Joined: Jul 2005
Posts: 2
S
Setter Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
S
Joined: Jul 2005
Posts: 2
This is embarassing.. The reason it crashed was because I forgot to put LoadDll in exports clause.
Thanks for the hint.