12#pragma clang diagnostic push
13#pragma clang diagnostic ignored "-Wextra-tokens"
18#pragma clang diagnostic pop
35HMODULE GetHModule() {
return static_cast<HMODULE
>(
g_hModule); }
40 typedef std::unique_ptr<ITypeLib, void(*)(IUnknown*
p)> ITypeLibGuard;
41 static ITypeLibGuard s_aITypeLibGuard = [] {
42 ITypeLibGuard aITypeLibGuard(
nullptr, [](IUnknown*
p) {
if (
p)
p->Release(); });
44 if (GetModuleFileNameW(GetHModule(), szFile,
MAX_PATH) == 0)
45 return aITypeLibGuard;
47 if (FAILED(LoadTypeLib(szFile, &pTypeLib)))
48 return aITypeLibGuard;
49 aITypeLibGuard.reset(pTypeLib);
50 return aITypeLibGuard;
52 return s_aITypeLibGuard.get();
57 static wchar_t* s_sPath = []() ->
wchar_t* {
59 if (GetModuleFileNameW(GetHModule(), sPath,
MAX_PATH) == 0)
61 wchar_t* pSlashPos = wcsrchr(sPath, L
'\\');
62 if (pSlashPos ==
nullptr)
64 wcscpy(pSlashPos + 1, L
"spsupp_helper.exe");
76 case DLL_PROCESS_ATTACH:
80 case DLL_THREAD_ATTACH:
81 case DLL_THREAD_DETACH:
82 case DLL_PROCESS_DETACH:
90 const IID CLSID_spsupp =
91 { 0xf1924d0c, 0x9b35, 0x4a46, { 0xbc, 0xde, 0xcf, 0xef, 0x2c, 0xe6, 0x7a, 0x17 } };
97 if (IsEqualIID(rclsid, CLSID_spsupp))
104 return CLASS_E_CLASSNOTAVAILABLE;
121 return ResultFromScode(SELFREG_E_TYPELIB);
124 if (GetModuleFileNameW(GetHModule(), szFile,
MAX_PATH) == 0)
125 return HRESULT_FROM_WIN32(GetLastError());
127 HRESULT
hr = RegisterTypeLib(pTypeLib, szFile,
nullptr);
133 .
RegisterObject(LIBID_spsupp, L
"LOSPSupport", L
"OpenDocuments", { 5, 1, 2, 3, 4 }, szFile);
140 return ResultFromScode(SELFREG_E_TYPELIB);
142 HRESULT
hr = pTypeLib->GetLibAttr(&pLibAttr);
145 auto ReleaseFunc = [pTypeLib](TLIBATTR*
p) {
if (
p) pTypeLib->ReleaseTLibAttr(
p); };
146 typedef std::unique_ptr<TLIBATTR,
decltype(ReleaseFunc)> TLIBATTRGuard;
147 static TLIBATTRGuard aTLIBATTRGuard(
nullptr, ReleaseFunc);
149 hr = UnRegisterTypeLib(pLibAttr->guid, pLibAttr->wMajorVerNum, pLibAttr->wMinorVerNum, pLibAttr->lcid, pLibAttr->syskind);
162 if (wcscmp(pszCmdLine, L
"Substitute_OWSSUPP") == 0)
169 hr = registrar.
RegisterProgIDs(L
"SharePoint", L
"OpenDocuments", { 5, 1, 2, 3, 4 });
static LONG GetObjectCount()
ULONG STDMETHODCALLTYPE Release() override
static LONG GetObjectCount()
static LONG GetLockCount()
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject) override
HRESULT RegisterProgIDs(const wchar_t *sProgram, const wchar_t *sComponent, std::initializer_list< int > aVersions)
HRESULT RegisterObject(REFIID riidTypeLib, const wchar_t *sProgram, const wchar_t *sComponent, std::initializer_list< int > aVersions, const wchar_t *Path)
HRESULT UnRegisterObject(const wchar_t *sProgram, const wchar_t *sComponent, std::initializer_list< int > aVersions)
HRESULT UnRegisterProgIDs(const wchar_t *sProgram, const wchar_t *sComponent, std::initializer_list< int > aVersions)
static HINSTANCE g_hModule
const wchar_t *typedef BOOL
STDAPI DllRegisterServer(void)
BOOL APIENTRY DllMain(HANDLE hinstDLL, DWORD fdwReason, LPVOID)
STDAPI DllUnregisterServer(void)
STDAPI DllInstall(BOOL bInstall, _In_opt_ PCWSTR pszCmdLine)
const wchar_t * GetHelperExe()
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppvOut)
STDAPI DllCanUnloadNow(void)