abstract:
{Type define}
TDllAuthenticate = procedure(mailId, mailPass: PChar; isNated:LongBool; loginWindowHandle:HWND);
{in private}
DllAuthenticate : TDllAuthenticate;
{public method for dll forms}
procedure Authenticate (mailId, mailPass: PChar; isNated:LongBool; loginWindowHandle:HWND);
{implementation}
procedure TDllOtengoCore.Authenticate(mailId, mailPass: PChar;
isNated: LongBool; loginWindowHandle: HWND);
begin
if initCalled = false then
begin
init;
end;
if @DllAuthenticate = nil then
begin
@DllAuthenticate := GetProcAddress(dllHandle, _Authenticate);
end;
DllAuthenticate(mailId, mailPass, 0, loginWindowHandle);
end;
{Type define}
TDllAuthenticate =
procedure
(
mailId, mailPass:
PChar
; isNated:LongBool; loginWindowHandle:HWND
)
;
{in private}
DllAuthenticate : TDllAuthenticate;
{public method for dll forms}
procedure
Authenticate
(
mailId, mailPass:
PChar
; isNated:LongBool; loginWindowHandle:HWND
)
;
{implementation}
procedure
TDllOtengoCore.
Authenticate
(
mailId, mailPass:
PChar
;
isNated: LongBool; loginWindowHandle: HWND
)
;
begin
if
initCalled =
false
then
begin
init;
end
;
if
@DllAuthenticate =
nil
then
begin
@DllAuthenticate := GetProcAddress
(
dllHandle, _Authenticate
)
;
end
;
DllAuthenticate
(
mailId, mailPass,
0
, loginWindowHandle
)
;
end
;
When i called this method, i debuged the C version of dll with Delphi generated EXE file. In first function, the SetFilePath of C receive the exact string to it's Char * to pointer, which i am sending via Delphi.
But in Authenticate method, when i send "mailID", "password" i am receiving "BAD POINTER" or some "GARBAGE" value. I have tried so many alternates but failed, can you people help me to figure out the problem.
I have been working on DLL which is to be called from DELPHI. The dll is made in VC 2005. There are couple of functions which i am calling, the first 2 functions are being called without any problem, however i am having problem in Third function.
The prototype of those function in C are
C Code:
[url=#top]
[/url]Original
- C Code
__declspec (dllexport ) void WINAPI SetFilePath(char * filepath)- __declspec
- (
- dllexport
- )
- void
- WINAPI SetFilePath
- (
- char
- * filepath
- )
Copy Code I mapped it on DELPHI as
Delphi Code:
[url=#top]
[/url]Original
- Delphi Code
TDllSetFilePath = procedure (path : PChar); stdcall;
{rest declatrations}
DllSetFilePath : TDllSetFilePath; {in private section}
{...}
procedure SetFilePath (FilePath : PChar); {a public method to be called in delphi}
implementation
procedure TDllOtengoCore.SetFilePath(FilePath: PChar);
begin
if initCalled = false then
begin
init; {ensures that dll is loaded}
end;
if @DllSetFilePath = nil then
begin
@DllSetFilePath := GetProcAddress(dllHandle, _SetFilePath); {_Setfile path is defined globally to cover name mangling}
end;
DllSetFilePath(FilePath);
end;- TDllSetFilePath =
- procedure
- (
- path :
- PChar
- )
- ; stdcall;
- {rest declatrations}
- DllSetFilePath : TDllSetFilePath;
- {in private section}
- {...}
- procedure
- SetFilePath
- (
- FilePath :
- PChar
- )
- ;
- {a public method to be called in delphi}
- implementation
- procedure
- TDllOtengoCore.
- SetFilePath
- (
- FilePath:
- PChar
- )
- ;
- begin
- if
- initCalled =
- false
- then
- begin
- init;
- {ensures that dll is loaded}
- end
- ;
- if
- @DllSetFilePath =
- nil
- then
- begin
- @DllSetFilePath := GetProcAddress
- (
- dllHandle, _SetFilePath
- )
- ;
- {_Setfile path is defined globally to cover name mangling}
- end
- ;
- DllSetFilePath
- (
- FilePath
- )
- ;
- end
- ;
Copy Code Similarly i was able to call "start" method as well of dll which accept no parameter.
But when i am trying to call another method, I am having problems.
C Prototype
C Code:
[url=#top]
[/url]Original
- C Code
__declspec (dllexport)
void WINAPI Authenticate(char * emailaddrs, char * password, BOOL isnated, HWND loginwindowhandle)- __declspec
- (
- dllexport
- )
- void
- WINAPI Authenticate
- (
- char
- * emailaddrs,
- char
- * password, BOOL isnated, HWND loginwindowhandle
- )
Copy Code In delphi,
Delphi Code:
[url=#top]
[/url]Original
- Delphi Code
{Type define}
TDllAuthenticate = procedure(mailId, mailPass: PChar; isNated:LongBool; loginWindowHandle:HWND);
{in private}
DllAuthenticate : TDllAuthenticate;
{public method for dll forms}
procedure Authenticate (mailId, mailPass: PChar; isNated:LongBool; loginWindowHandle:HWND);
{implementation}
procedure TDllOtengoCore.Authenticate(mailId, mailPass: PChar;
isNated: LongBool; loginWindowHandle: HWND);
begin
if initCalled = false then
begin
init;
end;
if @DllAuthenticate = nil then
begin
@DllAuthenticate := GetProcAddress(dllHandle, _Authenticate);
end;
DllAuthenticate(mailId, mailPass, 0, loginWindowHandle);
end;- {Type define}
- TDllAuthenticate =
- procedure
- (
- mailId, mailPass:
- PChar
- ; isNated:LongBool; loginWindowHandle:HWND
- )
- ;
- {in private}
- DllAuthenticate : TDllAuthenticate;
- {public method for dll forms}
- procedure
- Authenticate
- (
- mailId, mailPass:
- PChar
- ; isNated:LongBool; loginWindowHandle:HWND
- )
- ;
- {implementation}
- procedure
- TDllOtengoCore.
- Authenticate
- (
- mailId, mailPass:
- PChar
- ;
- isNated: LongBool; loginWindowHandle: HWND
- )
- ;
- begin
- if
- initCalled =
- false
- then
- begin
- init;
- end
- ;
- if
- @DllAuthenticate =
- nil
- then
- begin
- @DllAuthenticate := GetProcAddress
- (
- dllHandle, _Authenticate
- )
- ;
- end
- ;
- DllAuthenticate
- (
- mailId, mailPass,
- 0
- , loginWindowHandle
- )
- ;
- end
- ;
Copy Code When i called this method, i debuged the C version of dll with Delphi generated EXE file. In first function, the SetFilePath of C receive the exact string to it's Char * to pointer, which i am sending via Delphi.
But in Authenticate method, when i send "mailID", "password" i am receiving "BAD POINTER" or some "GARBAGE" value. I have tried so many alternates but failed, can you people help me to figure out the problem. |