Use CppWinRTClassFactory to implement DllGetClassObject?
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 3k
- Forks
- 300
- Avg merge
- 19h 12m
- Merged PRs (30d)
- 1
Description
I've just started modernizing some existing ATL projects to WinRT. One challenge then faced has been how to implement DllGetClassObject in a DLL-based COM server. ATL already includes boilerplate code for this, but similar functionality seem to be missing from C++/WinRT and WIL.
There's documentation on how to implement DllGetClassObject with a custom class factory on Author COM components with C++/WinRT. This works fine, but require developers to add their own class factory implementation, which leads to boilerplate.
To reduce boilerplate, I've started using the WIL CppWinRTClassFactory class to simplify the DllGetClassObject implementation, and then end up with code like this:
STDAPI DllGetClassObject(::GUID const& clsid, ::GUID const& iid, void** result) {
*result = nullptr;
if (clsid == __uuidof(MyServer)) {
return winrt::make<wil::details::CppWinRTClassFactory<MyServer>>().as(iid, result);
}
return CLASS_E_CLASSNOTAVAILABLE;
}
This works fine, but introduces a dependency to a wil::details class, and I'm unsure if this is recommended.
REQUEST: There's already a wil::register_com_server function in this repo to ease implementation of EXE-based COM servers. It would therefore be great if something similar could exist for DLL-based COM servers. One solution could then be to endorse direct CppWinRTClassFactory usage, or provide a more complete DllGetClassObject implementation.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the existing wil::register_com_server implementation and the C++/WinRT “Author COM components with C++/WinRT” guidance, then compare the shown CppWinRTClassFactory usage with the public APIs in this repository. Done means an agreed DLL-based COM-server approach that avoids relying on an internal wil::details type and is documented or implemented consistently with the existing EXE support.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- operating-systems
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100