Link to home
Start Free TrialLog in
Avatar of d32coder
d32coder

asked on

dll help

Now on to learning about DLLs.  Seems easy enough..
mIRC can use a DLL with this calling convention:

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

  mWnd is the handle to the main mIRC window.
  aWnd is the handle of the window in which the command is being issued, this might not be the currently active window if the command is being called by a remote script.
  data is the information that you wish to send to the DLL. On return, the DLL can fill this variable with the command it wants mIRC to perform if any.
  parms is filled by the DLL on return with parameters that it wants mIRC to use when performing the command that it returns in the data variable.
( I'm not going to edit the boolean parameters )
----------------
I wrote this (conversion).  I want to assign a value to the 2 PChar parameters before returning a value of 2.
...
function TestString(mWnd,aWnd: THandle; data, parms: PChar; show,nopause: Boolean): integer; Stdcall;
begin
 data := '/msg $me ';
 parms := 'Successful test!';
 Result := 2;
end;

exports TestString;
begin
end.

----
It seems like I am assigning values to a local copy of the PChars as the caller is using the original default values after the call.  I need to plug the new Char-Strings into the memory slot where the original PChar values are (overwrite).  Am I close?

Don
ASKER CERTIFIED SOLUTION
Avatar of robert_marquardt
robert_marquardt

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I don't understand your TestString function? ? if you have defined the procname function from the DLL by

procname(mWnd,aWnd: THandle; data, parms: PChar; show,nopause: Boolean): integer; Stdcall;

then you could try to call it with

procedure TForm1.ButtonClick(Sender: TObject);
var
Result: Integer;
Data, Params: PChar;
hMirc: THandle;
begin
data := '/msg $me ';
parms := 'Successful test!';
hMirc := {some fuction to get MIRC handle}
Result := procname(hMirc,Handle, data, parms, True,False);
if Result = 2 then
ShowMessage('I got 2');
end;
Avatar of d32coder
d32coder

ASKER

Exactly.  Thanks Robert.