Recent

Author Topic: activex.pp DllGetClassObject problem  (Read 1080 times)

440bx

  • Hero Member
  • *****
  • Posts: 6148
activex.pp DllGetClassObject problem
« on: August 11, 2025, 09:04:53 pm »
Hello,

DllGetClassObject is one of those functions that needs to be implemented by a dll that supports COM.  Because of that there are as many implementations of it as there are dlls that support COM.

It is unusual for an application to call it directly but, if it needs to call it directly, it should use GetProcAddress to get the address of the dll specific implementation it needs to call.  IOW, DllGetClassObject's operation is dll specific.

activex.pp defines DllGetClassObject and it shouldn't because if someone calls DllGetClassObject they'll likely be calling the ole32 implementation instead of the implementation that applies to whatever dll is of interest at the time.

Simply stated, there should not be a way to statically call DllGetClassObject because the call is ambiguous because it is dll specific. 

HTH.
FPC v3.2.2 and Lazarus v4.0rc3 on Windows 7 SP1 64bit.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12712
  • FPC developer.
Re: activex.pp DllGetClassObject problem
« Reply #1 on: August 11, 2025, 09:48:38 pm »
But all those dlls must be registered, and that is what the ole32 version retrieves? It looks up and calls the registered DLL implementation ?

440bx

  • Hero Member
  • *****
  • Posts: 6148
Re: activex.pp DllGetClassObject problem
« Reply #2 on: August 11, 2025, 10:02:27 pm »
Some of these functions, DllGetClassObject among them are for COM to use.  They are not meant to be used by an app.

Here is, among other things, what the documentation states in DllGetClassObject:
Quote
Notes to Callers
You should not call DllGetClassObject directly. When an object is defined in a DLL, CoGetClassObject calls the CoLoadLibrary function to load the DLL, which, in turn, calls DllGetClassObject.
The really critical thing is that, like some other COM related functions, DllGetClassObject is different for every dll that implements it.  Because of this, there should not be a DllGetClassObject exported from any dll since, a dll specific pointer to it must be obtained first to ensure the correct/desired implementation is called.

FPC v3.2.2 and Lazarus v4.0rc3 on Windows 7 SP1 64bit.

PascalDragon

  • Hero Member
  • *****
  • Posts: 6354
  • Compiler Developer
Re: activex.pp DllGetClassObject problem
« Reply #3 on: August 14, 2025, 08:33:17 pm »
Delphi's ActiveX unit doesn't provide DllGetClassObject (or DllCanUnloadNow) for what it's worth...

 

TinyPortal © 2005-2018