tags:

views:

131

answers:

4

Hi there, I'm a total newbie regarding to DLL. And I don't need to creat them I just need to use one. I've read some tutorials, but they weren't as helpful as I hoped.

Here's the way I started: I've downloaded the SDK which I need to use (ESTOS Tapi Server). I read in the docs and spotted out the DLL which I need to use, which is the ENetSN.dll, and so I registered it.

Next I've used the Dependency Walker to take a look at the DLL - and I was wondering because there are only these functions: DllCanUnloadNow, DllGetClassObject, DllRegisterServer and DllUnregisterServer, and these are not the functions mentioned in the docs.

I think I have to call DllGetClassObject to get an object out of the DLL with which I can start to work. Unfortunately the tutorials I found doesn't mentioned how this is done (or I didn't understood it).

There are also 3 exmaples delivered for VB and C++, but I wasn't able to 'translate' them into delphi.

If somebody knows a tutorial where this is explained or could give me a pointer to the right direcetion, I would be very thankful .

+4  A: 

The the 3 exported functions indicate that its a COM/ActiveX DLL, If you have registered it with a bit of luck you can get at it via Project->Import Type Library.

Alex K.
Thanks, that worked ;)The wikipedia entry about COM was also very helpful to me.
doubleu
A: 

If you want to call the Dll Procedure or function in your application, then follow this process

procedure TForm1.DllBtnClick(Sender: TObject);

  {Step: 1 To call DLL procedure/function from your program, you first have to 
  declare a type that describes the procedure:}

type
  TSayHello = procedure(pParam: Parameters in the Dll Procedure); 
var
  DLLInstance : THandle;
  SayHello : TSayHello;
begin

  {Step 2: You must load the library}

  DLLInstance := LoadLibrary(`c:\Mydll.dll');
  if DLLInstance = 0 then begin
    MessageDlg(`Unable to load DLL.', mtError, [mbOK], 0);
    Exit;
  end;

  {Step : 3 Get the address of the procedure using GetProcAddress. }

  @SayHello := GetProcAddress(DLLInstance, 'SayHello');
  if @SayHello <> nil then

  {Step: 4 Call your function}

    SayHello(Self)  
  else
    MessageDlg(`Unable to locate procedure.', mtError, [mbOK], 0);

  {Step: 5 Free the Dll}

  FreeLibrary(DLLInstance);
end;
Bharat
Generally correct but not applicable here as the OP is obviously dealing with a COM-library which you interact with in a very different manner.
Oliver Giesen
+3  A: 

Forget about the library being a DLL. Judging from the fact that you had to register the DLL and from the functions it exports, it's a COM/OLE/ActiveX-library. For these you don't care about them being DLLs. Instead you work with them by creating instances of the COM-classes contained therein. Lookup CreateComObject, CreateAutoObject and similar methods. When using the type library importer (see Alex K's post) you might even get a couple of (likely non-visual) components to work with.

Oliver Giesen
+2  A: 

You may want to check out Delphi 2010's new feature of delayed loading libraries (DLLs). See http://www.drbob42.com/examines/examinC1.htm for an article and more details.

Bob Swart
again, correct but not applicable here.
Oliver Giesen