3

How can I get WRL to link my object into its activation factory?

 1 year ago
source link: https://devblogs.microsoft.com/oldnewthing/20220922-00/?p=107206
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

How can I get WRL to link my object into its activation factory?

RaymondChen_5in-150x150.jpg

Raymond Chen

September 22nd, 20220 0

Recall that under the classical model for linking, symbols in libraries are not included unless they or some other symbol in the same object file is referenced by an explicitly-included object file, or indirectly via a chain of object files.

Component libraries like ATL and WRL use a linker trick to create self-registering objects. ATL has a set of object map macros for doing this, and WRL has its own macros for activatable objects and COM-creatable objects.

But if your object is in a static library, you need to do something to pull in those object files.

For ATL, Larry Osterman used the trick of calling two dummy functions in the object file from dead code.

WRL codifies the mechanism with a set of macros that create explicit references to the magic objects:

#define WrlCreatorMapIncludePragma(className)
#define WrlCreatorMapIncludePragmaex(className, serverName)
#define CoCreatableClassWrlCreatorMapInclude(className)
#define CoCreatableClassWrlCreatorMapIncludeEx(className, serverName)

Invoke those macros somewhere in the main project (next to your DllMain is a fairly obvious place), and they will pull in the object registration information.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK