Board index » delphi » [MS 4.0 C DLL] Help Problem with C DLL from Delphi 2.01 program.

[MS 4.0 C DLL] Help Problem with C DLL from Delphi 2.01 program.

Hi all,

Can anyone inform me if there is any thing special you need to
do to access MS C DLL's from Delphi 2.01.

I am trying to call a function that displays a Dialog box but NT 3.51
just returns -1.

Does the C functions need to be defined in any special way PASCAL
headers

Do I need to call the functions with any special attribs it
STDCALL,PASCAL

he following bit of code is what who I am defining the calls to the
DLL.

unit NDSDLL;

interface
Uses Windows;

Function  InitNDSLib(Window:HWnd;AppName:String):Boolean;
Function  CloseNDSLib(Window:HWnd;AppName:String):Boolean;
Function  DoPropertySheet(Window:hWnd):Integer;
Function  NWNDSCreateUser(ObjectName:String;
                          UserId:String;
                          FirstName:String;
                          LastName:String;
                          EMailAddress:String;
                          Department:String;
                          PhoneNo:String;
                          StartYear:Integer;
                          Password:String;
                          UserType:Word;
                          BaseSite:String):Integer;

implementation

Function  InitNDSLib;      external 'NDSUSERLIB.DLL'
Function  CloseNDSLib;     external 'NDSUSERLIB.DLL'
Function  DoPropertySheet; external 'NDSUSERLIB.DLL'
Function  NWNDSCreateUser; external 'NDSUSERLIB.DLL'

All I am trying to do is pass the Window handle of Form1 to a function
so that it can display the dialog.

But the DLL is retuning Invalid Parent Handle.

The I am using for the Call is:

procedure TForm1.Button1Click(Sender: TObject);
begin
DoPropertySheet(Handle);
Label1.Caption:=IntToStr(Handle);
end;

One last thing.

While trying to fiqure out what is wrong with my Handle I check out
Winsight32 to check my Window Handle even thats different to the
the Handle displayed on my form.

Thanks for your time.

 

Re:[MS 4.0 C DLL] Help Problem with C DLL from Delphi 2.01 program.


Quote
Huet Bartels <Hu...@Mdx.ac.uk> wrote:
>Hi all,
>Can anyone inform me if there is any thing special you need to
>do to access MS C DLL's from Delphi 2.01.
>I am trying to call a function that displays a Dialog box but NT 3.51
>just returns -1.
>Does the C functions need to be defined in any special way PASCAL
>headers
>Do I need to call the functions with any special attribs it
>STDCALL,PASCAL

The stdcall should be used with any functions in windows that use the
PASCAL calling conventions.  In D2, Borland changed the calling
conventions of the function/procedures.  

Re:[MS 4.0 C DLL] Help Problem with C DLL from Delphi 2.01 program.


In message <4vshcb$...@cobweb.aracnet.com>, ilcrw...@aracnet.com (Iman L. Crawford) said:

Quote
> The stdcall should be used with any functions in windows that use the
> PASCAL calling conventions.

Err, no.

The stdcall attribute is used with windows functions that use the stdcall
calling convention. The pascal calling convention is different.

Quote
>  In D2, Borland changed the calling
> conventions of the function/procedures.  

Yes, D1 default was pascal, D2 is fastcall. However, just to make life more
amusing, Microsoft *also* changed the default for Windows API and DLL
functions from pascal in Win16 to stdcall in Win32.

However, provided the caller and callee agree, any of the calling
conventions can be used. Just remember they have to agree...
-----------------------------------------------------------------------
Steve Rencontre               |  st...@dstrip.demon.co.uk (business)
If it works, it's obsolete.   |  steve...@cix.compulink.co.uk (private)
-----------------------------------------------------------------------

Other Threads