delphi programming forums mysql charset mget recursive synonimos
free ventrilo servers hosting cs javascript delay python find in list
Back Forum New
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)
  1. __declspec
  2. (
  3. dllexport
  4. )
  5. void
  6. WINAPI SetFilePath
  7. (
  8. char
  9. * filepath
  10. )
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;
  1. TDllSetFilePath =
  2. procedure
  3. (
  4. path :
  5. PChar
  6. )
  7. ; stdcall;
  8. {rest declatrations}
  9. DllSetFilePath : TDllSetFilePath;
  10. {in private section}
  11. {...}
  12. procedure
  13. SetFilePath
  14. (
  15. FilePath :
  16. PChar
  17. )
  18. ;
  19. {a public method to be called in delphi}
  20. implementation
  21. procedure
  22. TDllOtengoCore.
  23. SetFilePath
  24. (
  25. FilePath:
  26. PChar
  27. )
  28. ;
  29. begin
  30. if
  31. initCalled =
  32. false
  33. then
  34. begin
  35.         init;
  36. {ensures that dll is loaded}
  37. end
  38. ;
  39. if
  40. @DllSetFilePath =
  41. nil
  42. then
  43. begin
  44.         @DllSetFilePath := GetProcAddress
  45. (
  46. dllHandle, _SetFilePath
  47. )
  48. ;
  49. {_Setfile path is defined globally to cover name mangling}
  50. end
  51. ;
  52.     DllSetFilePath
  53. (
  54. FilePath
  55. )
  56. ;
  57. end
  58. ;
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)
  1. __declspec
  2. (
  3. dllexport
  4. )
  5. void
  6. WINAPI Authenticate
  7. (
  8. char
  9. * emailaddrs,
  10. char
  11. * password, BOOL isnated, HWND loginwindowhandle
  12. )
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;
  1. {Type define}
  2.         TDllAuthenticate =
  3. procedure
  4. (
  5. mailId, mailPass:
  6. PChar
  7. ; isNated:LongBool; loginWindowHandle:HWND
  8. )
  9. ;
  10. {in private}
  11. DllAuthenticate : TDllAuthenticate;
  12. {public method for dll forms}
  13. procedure
  14. Authenticate
  15. (
  16. mailId, mailPass:
  17. PChar
  18. ; isNated:LongBool; loginWindowHandle:HWND
  19. )
  20. ;
  21. {implementation}
  22. procedure
  23. TDllOtengoCore.
  24. Authenticate
  25. (
  26. mailId, mailPass:
  27. PChar
  28. ;
  29.   isNated: LongBool; loginWindowHandle: HWND
  30. )
  31. ;
  32. begin
  33. if
  34. initCalled =
  35. false
  36. then
  37. begin
  38.         init;
  39. end
  40. ;
  41. if
  42. @DllAuthenticate =
  43. nil
  44. then
  45. begin
  46.         @DllAuthenticate := GetProcAddress
  47. (
  48. dllHandle, _Authenticate
  49. )
  50. ;
  51. end
  52. ;
  53.     DllAuthenticate
  54. (
  55. mailId, mailPass,
  56. 0
  57. , loginWindowHandle
  58. )
  59. ;
  60. end
  61. ;
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.

TOP


Code:
  1. #
  2. {Type define}
  3. #
  4.         TDllAuthenticate = procedure(mailId, mailPass: PChar; isNated:LongBool; loginWindowHandle:HWND);
  5. #
Copy Code
I don't see a calling convention declared.

TOP

yeah ... .. thanks ...



{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.

TOP

Back Forum