[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

dll help

Posted on 2002-06-13
3
Medium Priority
?
216 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
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…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
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.…
Suggested Courses

656 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