[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

dll help

Posted on 2002-06-13
3
Medium Priority
?
217 Views
Last Modified: 2010-04-04
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
0
Comment
Question by:d32coder
3 Comments
 
LVL 11

Accepted Solution

by:
robert_marquardt earned 800 total points
ID: 7077197
function TestString(mWnd,aWnd: HWND;
// not wrong, but this is better
 data, parms: PChar;
// BOOL is LongBool (program may crash otherwise)
show,nopause: LongBool): integer; Stdcall;

You assign a local variable (pointer) = data and parms to point to a new location (your literal string constants).
On return the parameter is deleted from the stack and you lose it.
You will have to hand in pointers to buffers and copy the data  to the location pointed to by the parameters.
Something like StrCopy.
0
 
LVL 34

Expert Comment

by:Slick812
ID: 7077213
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;
0
 

Author Comment

by:d32coder
ID: 7077435
Exactly.  Thanks Robert.

0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question