DLLEXPORT STDAPI DllRegisterServer(VOID) { if (!EnsureRegKey(g_lpRegKey)) return E_UNEXPECTED; WCHAR szPath[MAX_PATH]; GetModuleFileName(g_hInstance, szPath, MAX_PATH); if (!SetRegValue(g_lpRegKey, L"Description", L"SumatraPDF Browser Plugin") || !SetRegValue(g_lpRegKey, L"Path", szPath) || !SetRegValue(g_lpRegKey, L"Version", CURR_VERSION_STR) || !SetRegValue(g_lpRegKey, L"ProductName", L"SumatraPDF Browser Plugin")) { return E_UNEXPECTED; } ScopedMem<WCHAR> mimeType(str::Join(g_lpRegKey, L"\\MimeTypes\\application/pdf")); EnsureRegKey(mimeType); mimeType.Set(str::Join(g_lpRegKey, L"\\MimeTypes\\application/vnd.ms-xpsdocument")); EnsureRegKey(mimeType); mimeType.Set(str::Join(g_lpRegKey, L"\\MimeTypes\\application/oxps")); EnsureRegKey(mimeType); mimeType.Set(str::Join(g_lpRegKey, L"\\MimeTypes\\image/vnd.djvu")); EnsureRegKey(mimeType); mimeType.Set(str::Join(g_lpRegKey, L"\\MimeTypes\\image/x-djvu")); EnsureRegKey(mimeType); mimeType.Set(str::Join(g_lpRegKey, L"\\MimeTypes\\image/x.djvu")); EnsureRegKey(mimeType); return S_OK; }
DLLEXPORT STDAPI DllRegisterServer(VOID) { if (!EnsureRegKey(g_lpRegKey)) return E_UNEXPECTED; WCHAR szPath[MAX_PATH]; GetModuleFileName(g_hInstance, szPath, MAX_PATH); if (!SetRegValue(g_lpRegKey, L"Description", L"SumatraPDF Browser Plugin") || !SetRegValue(g_lpRegKey, L"Path", szPath) || !SetRegValue(g_lpRegKey, L"Version", L"0") || !SetRegValue(g_lpRegKey, L"ProductName", L"SumatraPDF Browser Plugin")) { return E_UNEXPECTED; } ScopedMem<WCHAR> mimeType(str::Join(g_lpRegKey, L"\\MimeTypes\\application/pdf")); EnsureRegKey(mimeType); mimeType.Set(str::Join(g_lpRegKey, L"\\MimeTypes\\application/vnd.ms-xpsdocument")); EnsureRegKey(mimeType); mimeType.Set(str::Join(g_lpRegKey, L"\\MimeTypes\\application/oxps")); EnsureRegKey(mimeType); mimeType.Set(str::Join(g_lpRegKey, L"\\MimeTypes\\image/vnd.djvu")); EnsureRegKey(mimeType); mimeType.Set(str::Join(g_lpRegKey, L"\\MimeTypes\\image/x-djvu")); EnsureRegKey(mimeType); mimeType.Set(str::Join(g_lpRegKey, L"\\MimeTypes\\image/x.djvu")); EnsureRegKey(mimeType); // Work around Mozilla bug https://bugzilla.mozilla.org/show_bug.cgi?id=581848 which // makes Firefox up to version 3.6.* ignore all but the first plugin for a given MIME type // (per http://code.google.com/p/sumatrapdf/issues/detail?id=1254#c12 Foxit does the same) *(WCHAR *)path::GetBaseName(szPath) = '\0'; if (SHGetValue(HKEY_CURRENT_USER, L"Environment", L"MOZ_PLUGIN_PATH", NULL, NULL, NULL) == ERROR_FILE_NOT_FOUND) { WriteRegStr(HKEY_CURRENT_USER, L"Environment", L"MOZ_PLUGIN_PATH", szPath); SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, (LPARAM)L"Environment", SMTO_ABORTIFHUNG, 5000, NULL); } return S_OK; }