https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c6ec8d924e59a958ff78e…
commit c6ec8d924e59a958ff78e4371ac0a09c67b00f3f
Author: Whindmar Saksit <whindsaks(a)proton.me>
AuthorDate: Mon Nov 13 11:03:05 2023 +0100
Commit: GitHub <noreply(a)github.com>
CommitDate: Mon Nov 13 11:03:05 2023 +0100
[ATL] Added CComPtr.CoCreateInstance helper methods (#5905)
---
sdk/lib/atl/atlcomcli.h | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/sdk/lib/atl/atlcomcli.h b/sdk/lib/atl/atlcomcli.h
index a11b05ace36..e7c5fd32ca4 100644
--- a/sdk/lib/atl/atlcomcli.h
+++ b/sdk/lib/atl/atlcomcli.h
@@ -98,6 +98,19 @@ public:
p->Release();
}
+ HRESULT CoCreateInstance(REFCLSID rclsid, REFIID riid, LPUNKNOWN pOuter = NULL, DWORD
ClsCtx = CLSCTX_ALL)
+ {
+ ATLASSERT(!p);
+ return ::CoCreateInstance(rclsid, pOuter, ClsCtx, riid, (void**)&p);
+ }
+
+ HRESULT CoCreateInstance(LPCOLESTR ProgID, REFIID riid, LPUNKNOWN pOuter = NULL,
DWORD ClsCtx = CLSCTX_ALL)
+ {
+ CLSID clsid;
+ HRESULT hr = CLSIDFromProgID(ProgID, &clsid);
+ return FAILED(hr) ? hr : CoCreateInstance(clsid, riid, pOuter, ClsCtx);
+ }
+
T *operator = (T *lp)
{
T* pOld = p;
@@ -142,6 +155,16 @@ public:
return *this;
}
+
+ HRESULT CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pOuter = NULL, DWORD ClsCtx =
CLSCTX_ALL)
+ {
+ return CoCreateInstance(rclsid, __uuidof(T), pOuter, ClsCtx);
+ }
+
+ HRESULT CoCreateInstance(LPCOLESTR ProgID, LPUNKNOWN pOuter = NULL, DWORD ClsCtx =
CLSCTX_ALL)
+ {
+ return CoCreateInstance(ProgID, __uuidof(T), pOuter, ClsCtx);
+ }
#endif
void Release()