mIRC Home    About    Download    Register    News    Help

Print Thread
#101087 20/10/04 10:56 AM
Joined: Oct 2004
Posts: 11
C
Chesso Offline OP
Pikka bird
OP Offline
Pikka bird
C
Joined: Oct 2004
Posts: 11
I found a small tutorial on mircscripts about doing this but it doesnt quite help me with what im trying to do.

This is the function in my DLL... and works of course...

Function SendMessage(mWnd, aWnd: HWND; Data, parms: PChar; show, nopause: Boolean): Integer; Stdcall;
Begin
StrCopy(Data, 'Welcome');
Result := 3;
End;

If i type in mIRC: //echo -a $dll(MEF.dll, SendMessage, NOT_USED) it echo's the message in my function but what i want to do is get input from the command say a string of text for a dialog title or w/e.

#101088 20/10/04 12:25 PM
Joined: Dec 2002
Posts: 2,962
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
You mean you want to input data to the DLL function? Anything you put in the last parameter of $dll() (in your case: NOT_USED) is available in the Data variable (it's used for both input and output of the DLL).


Spelling mistakes, grammatical errors, and stupid comments are intentional.
#101089 21/10/04 02:08 AM
Joined: Oct 2004
Posts: 11
C
Chesso Offline OP
Pikka bird
OP Offline
Pikka bird
C
Joined: Oct 2004
Posts: 11
Thnx for that m8

Sorry to be annoying but could you possible show me an example of making a function to take parameters and get them like......

calling /dll witht he usual params plus some extra ones that i specify like Integer's for windows size n a string for a title im a bit lost as how to do it.

Not only is this my first dl for mIRC but my first dll so im not quite acquinted with how it all works.

Last edited by Chesso; 21/10/04 02:13 AM.
#101090 22/10/04 11:59 PM
Joined: Aug 2004
Posts: 24
B
Ameglian cow
Offline
Ameglian cow
B
Joined: Aug 2004
Posts: 24
In your SendMessage example (bad name for a function) the parameters are stored in the Data variable as a string (Ok PChar :rolleyes:).

You use your knowledge of delphi to parse that data variable and do whatever.

Last edited by Biggles; 22/10/04 11:59 PM.
#101091 23/10/04 12:56 PM
Joined: Dec 2002
Posts: 2,962
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
Sorry for the late response, I read the email notification of your post but forgot to reply. Anyway, here's a quick example function that takes input from Data and then fills it with a new value.
Code:
function Reverse(mWnd, aWnd: hWnd; Data, Parms: PChar; Show, NoPause: Boolean): Integer; stdcall;
var
  Temp: String;
  I: Integer;
begin
  SetLength(Temp, Length(Data));
  for I := 0 to Length(Data) do
  begin
    Temp[I] := Data[Length(Data)-I]; // Reversing string by retrieving characters from Data one at a time
  end;
  StrCopy(Data, PChar(Temp)); // Putting reversed string back into data
  Result := 3;
end;


Using $dll(something.dll, Reverse, hello there) would return ereht olleh

There's no direct way to pass more than one parameter to a DLL I'm afraid; the simplest way is to tokenize them somehow. For instance if you know the parameters won't have a semi-colon in them you can just use $dll(something.dll, SomeFunction, value1;value2;value3) and then parse Data inside the DLL.


Spelling mistakes, grammatical errors, and stupid comments are intentional.

Link Copied to Clipboard