MCPcopy Create free account
hub / github.com/clechasseur/pathcopycopy / COMPlugin

Method COMPlugin

PathCopyCopy/plugins/src/COMPlugin.cpp:35–68  ·  view source on GitHub ↗

Constructor. Will create an instance of the COM plugin. @param p_CLSID ID of COM co-class that implements the plugin.

Source from the content-addressed store, hash-verified

33 // @param p_CLSID ID of COM co-class that implements the plugin.
34 //
35 COMPlugin::COMPlugin(const CLSID& p_CLSID)
36 : Plugin(),
37 m_Id(p_CLSID),
38 m_cpPlugin(),
39 m_cpPluginGroup(),
40 m_cpPluginState(),
41 m_cpPluginIcon(),
42 m_Description()
43 {
44 // Immediately create the plugin instance and make sure it works.
45 HRESULT hRes = m_cpPlugin.CoCreateInstance(p_CLSID);
46 if (FAILED(hRes)) {
47 throw COMPluginError(hRes);
48 }
49 if (m_cpPlugin == nullptr) {
50 throw COMPluginError(E_FAIL);
51 }
52
53 // Immediately query for other interface implementations. This can fail.
54 m_cpPluginGroup = m_cpPlugin;
55 m_cpPluginState = m_cpPlugin;
56 m_cpPluginIcon = m_cpPlugin;
57
58 // Immediately get plugin description. It must work and return a non-empty string.
59 ATL::CComBSTR bstrDescription;
60 hRes = m_cpPlugin->get_Description(&bstrDescription);
61 if (FAILED(hRes)) {
62 throw COMPluginError(hRes);
63 }
64 if (bstrDescription == nullptr || bstrDescription.Length() == 0) {
65 throw COMPluginError(E_UNEXPECTED);
66 }
67 m_Description = (LPWSTR) bstrDescription;
68 }
69
70 //
71 // Returns the plugin's unique identifier.

Callers

nothing calls this directly

Calls 2

COMPluginErrorClass · 0.85
get_DescriptionMethod · 0.45

Tested by

no test coverage detected