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

Method DllRegisterServer

PathCopyCopy/src/dllmain.cpp:95–128  ·  view source on GitHub ↗

CPathCopyCopyModule::DllRegisterServer Registers this module's classes and type libraries. @param p_RegisterTypeLib Whether to register type libraries. @return Result code.

Source from the content-addressed store, hash-verified

93// @return Result code.
94//
95[[gsl::suppress(c.128)]]
96HRESULT CPathCopyCopyModule::DllRegisterServer(BOOL p_RegisterTypeLib /*= TRUE*/) throw()
97{
98 try {
99 // Check for per-user registration.
100 bool perUserRegistration = false;
101 HRESULT hRes = ATL::AtlGetPerUserRegistration(&perUserRegistration);
102 if (SUCCEEDED(hRes)) {
103 hRes = ATL::CAtlDllModuleT<CPathCopyCopyModule>::DllRegisterServer(p_RegisterTypeLib);
104 if (SUCCEEDED(hRes)) {
105 // Register our shell extensions as "approved". We do this here so that
106 // it can work in per-user installations.
107 AtlRegKey approvedKey;
108 LONG regRes = approvedKey.Open(perUserRegistration ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE,
109 L"Software\\Microsoft\\Windows\\CurrentVersion\\Extensions\\Approved",
110 true, KEY_QUERY_VALUE | KEY_SET_VALUE);
111 if (regRes == ERROR_SUCCESS) {
112 regRes = approvedKey.SetStringValue(L"{82CB99A2-2F18-4D5D-9476-54347E3B6720}",
113 L"PathCopyCopy Contextual Menu Handler");
114 }
115 if (regRes == ERROR_SUCCESS) {
116 regRes = approvedKey.SetStringValue(L"{16170CA5-25CA-4e6d-928C-7A3A974F4B56}",
117 L"PathCopyCopy Data Handler");
118 }
119 if (regRes != ERROR_SUCCESS) {
120 hRes = HRESULT_FROM_WIN32(regRes);
121 }
122 }
123 }
124 return hRes;
125 } catch (...) {
126 return E_UNEXPECTED;
127 }
128}
129
130//
131// CPathCopyCopyModule::DllUnregisterServer

Callers 1

DllRegisterServerFunction · 0.45

Calls 3

OpenMethod · 0.80
DllRegisterServerFunction · 0.70
SetStringValueMethod · 0.45

Tested by

no test coverage detected