jasongth
asked on
C++ Syntax to Delphi Syntax
Hi,
Anyone knows the direct correct equivalence of the following C++ declaration:
DWORD CopyToPc( LPCSTR szFileName, const DWORD& dwOno )
DWORD RmConnect( LPCSTR szHostName, WORD wPortNo )
I am trying to access these two functions from a C++ dll using Delphi "external" keyword (Static Integration of the DLL).
I was able to decipher the actual "name" or "index" in the dll using third party "PE Explorer".
function RmConnect( szHostName: LPCSTR; wPortNo: WORD ): LongInt; overload; stdcall;
external 'RM.dll' name '?RmConnect@CRmTcp@@UAEKPB DG@Z';//in dex 114; Is the function parameters correct?
The project was compiled and start-up fine. But when I tried to call the RmConnect activated with the button,
runtime error occurs with the following message:
Debugger Exception Notification:
Project XXX.exe raised exception class EAccessViolation with message 'Access violation at address
77E20315 in module 'user32.dll'. Write of address 00002713'. Process stopped. Use Step or Run to continue.
I used the return data type of DWORD or Longword for RmConnect but still have this
runtime error. Anyone has any idea on this?
Thanks in advance.
Anyone knows the direct correct equivalence of the following C++ declaration:
DWORD CopyToPc( LPCSTR szFileName, const DWORD& dwOno )
DWORD RmConnect( LPCSTR szHostName, WORD wPortNo )
I am trying to access these two functions from a C++ dll using Delphi "external" keyword (Static Integration of the DLL).
I was able to decipher the actual "name" or "index" in the dll using third party "PE Explorer".
function RmConnect( szHostName: LPCSTR; wPortNo: WORD ): LongInt; overload; stdcall;
external 'RM.dll' name '?RmConnect@CRmTcp@@UAEKPB
The project was compiled and start-up fine. But when I tried to call the RmConnect activated with the button,
runtime error occurs with the following message:
Debugger Exception Notification:
Project XXX.exe raised exception class EAccessViolation with message 'Access violation at address
77E20315 in module 'user32.dll'. Write of address 00002713'. Process stopped. Use Step or Run to continue.
I used the return data type of DWORD or Longword for RmConnect but still have this
runtime error. Anyone has any idea on this?
Thanks in advance.
Assuming normal C functions the first is :-
function CopyToPc(szFileName : PChar; var dwOno : Longword) : Longword;
where PChar is ^Char. The actual parameter is an array of bytes terminating by a zero byte. Using a Delphi string (FileName : string), you'd pass it as follows :-
FileName:='c:\mydir\myfile .ext';
Reply:=CopyToPc(PChar(File Name),dwOn o);
The second function has the same type of parameter, so you'll need to get that right as well.
function CopyToPc(szFileName : PChar; var dwOno : Longword) : Longword;
where PChar is ^Char. The actual parameter is an array of bytes terminating by a zero byte. Using a Delphi string (FileName : string), you'd pass it as follows :-
FileName:='c:\mydir\myfile
Reply:=CopyToPc(PChar(File
The second function has the same type of parameter, so you'll need to get that right as well.
ASKER
Hi Robert,
Just want to know more about this wrapper that you are writing as
I am trying to use this dll from within my delphi program.
Yeah, this is the MEL dll.
Just want to know more about this wrapper that you are writing as
I am trying to use this dll from within my delphi program.
Yeah, this is the MEL dll.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I have the files ready. Please contact me directly robert_marquardt@gmx.de
ASKER
Thanks, robert. Appreciate this effort greatly :)
ASKER
Hi Robert,
The wrapper dll is working fine in preliminary test such as connection and copy function.
Thanks, pal :)
The wrapper dll is working fine in preliminary test such as connection and copy function.
Thanks, pal :)
Also I've been looking it. Someone can send me ? Or any information about Mel Library.
brunosss@gmx.com
brunosss@gmx.com
I currently write a wrapper for it (i guess the version is 3.13).
The DLL MknEdmRm.dll exports C++ methods so they are not directly callable from Delphi.
I will write a wrapper DLL in MS VC++ which flattens the API to functions.