mIRC Home    About    Download    Register    News    Help

Print Thread
#106937 05/01/05 12:26 PM
Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Hello, I searched the forums for a DLL tutorial for Delphi 6 and I now have the following.

Code:
library andy;

uses
  Windows, SysUtils, Classes;

function test(mWnd, aWnd: HWND; data, parms: PChar; show, nopause:boolean):integer; stdcall;
begin
  StrCopy(data,'/.msg Nick ...');
  Result := 2;
End;

exports
  test;

{$R *.RES}

begin
end.


The DLL works fine, it's basically a test DLL, when you type /dll andy.dll test it performs "/.msg $me ...".

Basically you type /dll andy.dll test.

And instead of
<Andy> ...

I get two messages
<Andy>...
<Andy>+++

Etc. It doesn't have to be "... " or even "+++" I just simply want it to send two /msg's to $me anyone any ideas?

#106938 05/01/05 01:53 PM
Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
I haven't used delphi for a while, so there's probably a couple of errors in the syntax, but this should give you the idea...

Code:
function wsprintf(lpOut, lpFmt : PChar); cdecl; varargs;

function test(mWnd, aWnd: HWND; data, parms: PChar; show, nopause:boolean):integer; stdcall; begin  
  StrCopy(data,'$me');
  var me : string;
  me = SendMessage(mWnd,WM_USER + 101,0,0);
  wsprintf(data,'/.msg %s ...',me);  
  SendMessage(mWnd,WM_USER + 100,0,0);
  wsprintf(data,'/.msg %s ...',me);  
  SendMessage(mWnd,WM_USER + 100,0,0);
  Result := 2;
End;


New username: hixxy
#106939 05/01/05 02:07 PM
Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Nah dude this wont work, it dont compile.

#106940 05/01/05 02:24 PM
Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
Yeah you're right, I misread a tutorial about 'varargs', sorry.


New username: hixxy
#106941 05/01/05 02:30 PM
Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Hey dude it's cool, thanks. Any ideas or should I wait for someone else?

If you don't know it doesn't matter. Someone later may reply. grin

#106942 05/01/05 04:45 PM
Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
Nah sorry, I can't think of anything else.


New username: hixxy
#106943 05/01/05 04:54 PM
Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
No worried buddy. I did manage to find a way but it is so n00bish.
Code:
function msg(mWnd, aWnd: HWND; data, parms: PChar; show, nopause:boolean):integer; stdcall;
begin
  StrCopy(data,'/.msg Nick ... | /.msg Nick ...');
  Result := 2;
End;


Is there any decent tutorials for SendMessage using Delphi and what not?

I've e-mailed the author of the the Delphi 6 DLL tutorial to work with mIRC so I will wait to see what he says and to see if he can shed any light on it.

Thanks for your help. grin

#106944 05/01/05 05:03 PM
Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
Actually, this might work:

Code:
function msg(mWnd, aWnd: HWND; data, parms: PChar; show, nopause:boolean):integer; stdcall; begin
  StrCopy(data,'//.msg $me ...');  
  SendMessage(mWnd,WM_USER + 100,0,0);
  StrCopy(data,'//.msg $me ...');  
  SendMessage(mWnd,WM_USER + 100,0,0);
  Result := 3;
End;


New username: hixxy
#106945 05/01/05 05:21 PM
Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
[Error] andy.dpr(9): Undeclared identifier: 'WM_USER'

#106946 05/01/05 05:25 PM
Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
Ah, I think you need to include "Windows" and "Messages" in your Uses clause.


New username: hixxy
#106947 05/01/05 05:35 PM
Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Well thankfully, I'm getting no compilation errors however when I type /dll andy.dll msg no messages are sent to $me. frown

#106948 05/01/05 05:55 PM
Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
My mistake again, WM_USER + 100 should be WM_USER + 200 blush


New username: hixxy
#106949 05/01/05 06:17 PM
Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
You mean like this?
Code:
library andy;

uses
  Windows, SysUtils, Messages, Classes;

function msg(mWnd, aWnd: HWND; data, parms: PChar; show, nopause:boolean):integer; stdcall;
begin
StrCopy(data,'//msg $me ...');
SendMessage(mWnd,WM_USER + 200,0,0);
StrCopy(data,'//msg $me ...');
SendMessage(mWnd,WM_USER + 200,0,0);
Result := 3;
End;

exports
  msg;

{$R *.RES}

begin
end.

#106950 05/01/05 06:19 PM
Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
Yes.


New username: hixxy
#106951 05/01/05 06:21 PM
Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
It's a no go I'm afraid dude, still wont work. frown

#106952 05/01/05 07:44 PM
Joined: Dec 2002
Posts: 2,962
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
In order to use SendMessage you have to put the command to be sent in a mapped file, you can't just stick it in data.


Spelling mistakes, grammatical errors, and stupid comments are intentional.
#106953 05/01/05 07:53 PM
Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Thanks for this info, is there any CreateFileMapping() tutorials?


Link Copied to Clipboard