com_obj: Add CoCreateInstance constructor
When using winstd::com_obj<> as a member of another class and we want to create an instance of the object in another class' constructor, this comes convenient. Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
parent
fc0060d3bd
commit
1d206602e6
@ -84,6 +84,21 @@ namespace winstd
|
||||
WINSTD_DPLHANDLE_IMPL(com_obj, NULL)
|
||||
|
||||
public:
|
||||
///
|
||||
/// Creates a new instance of a class
|
||||
///
|
||||
/// \sa [CoCreateInstance function](https://msdn.microsoft.com/en-us/library/windows/desktop/ms686615.aspx)
|
||||
///
|
||||
com_obj(
|
||||
_In_ REFCLSID rclsid,
|
||||
_In_opt_ LPUNKNOWN pUnkOuter,
|
||||
_In_ DWORD dwClsContext)
|
||||
{
|
||||
HRESULT hr = CoCreateInstance(rclsid, pUnkOuter, dwClsContext, __uuidof(T), (LPVOID*)&m_h);
|
||||
if (FAILED(hr))
|
||||
throw com_runtime_error(hr, "CoCreateInstance failed");
|
||||
}
|
||||
|
||||
///
|
||||
/// Queries the object for another interface and creates new class with it
|
||||
///
|
||||
|
Loading…
x
Reference in New Issue
Block a user