comparison mupdf-source/platform/gl/gl-win32.c @ 2:b50eed0cc0ef upstream

ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4. The directory name has changed: no version number in the expanded directory now.
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 15 Sep 2025 11:43:07 +0200
parents
children
comparison
equal deleted inserted replaced
1:1d09e1dec1d9 2:b50eed0cc0ef
1 // Copyright (C) 2004-2021 Artifex Software, Inc.
2 //
3 // This file is part of MuPDF.
4 //
5 // MuPDF is free software: you can redistribute it and/or modify it under the
6 // terms of the GNU Affero General Public License as published by the Free
7 // Software Foundation, either version 3 of the License, or (at your option)
8 // any later version.
9 //
10 // MuPDF is distributed in the hope that it will be useful, but WITHOUT ANY
11 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 // FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
13 // details.
14 //
15 // You should have received a copy of the GNU Affero General Public License
16 // along with MuPDF. If not, see <https://www.gnu.org/licenses/agpl-3.0.en.html>
17 //
18 // Alternative licensing terms are available from the licensor.
19 // For commercial licensing, see <https://www.artifex.com/> or contact
20 // Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
21 // CA 94129, USA, for further information.
22
23 #ifdef _WIN32
24 #define WIN32_LEAN_AND_MEAN
25 #define _CRT_SECURE_NO_WARNINGS
26 #include <windows.h>
27 #include <commdlg.h>
28 #include <shellapi.h>
29 #include <stdio.h>
30
31 #define OPEN_KEY(parent, name, ptr) \
32 RegCreateKeyExA(parent, name, 0, 0, 0, KEY_WRITE, 0, ptr, 0)
33 #define SET_VALUE(parent, name, value) \
34 RegSetValueExA(parent, name, 0, REG_SZ, (const BYTE *)(value), (DWORD)strlen(value) + 1)
35
36 void win_install(void)
37 {
38 char command_str[2048], argv0[2048];
39 HKEY software, classes, mupdf;
40 HKEY supported_types, shell, open, command;
41 HKEY dotpdf, dotxps, dotcbz, dotepub, dotfb2;
42 HKEY pdf_progids, xps_progids, cbz_progids, epub_progids, fb2_progids;
43
44 GetModuleFileNameA(NULL, argv0, sizeof argv0);
45 _snprintf(command_str, sizeof command_str, "\"%s\" \"%%1\"", argv0);
46
47 OPEN_KEY(HKEY_CURRENT_USER, "Software", &software);
48 OPEN_KEY(software, "Classes", &classes);
49 {
50 OPEN_KEY(classes, "MuPDF", &mupdf);
51 {
52 OPEN_KEY(mupdf, "SupportedTypes", &supported_types);
53 {
54 SET_VALUE(supported_types, ".pdf", "");
55 SET_VALUE(supported_types, ".xps", "");
56 SET_VALUE(supported_types, ".cbz", "");
57 SET_VALUE(supported_types, ".epub", "");
58 SET_VALUE(supported_types, ".fb2", "");
59 }
60 RegCloseKey(supported_types);
61 OPEN_KEY(mupdf, "shell", &shell);
62 OPEN_KEY(shell, "open", &open);
63 OPEN_KEY(open, "command", &command);
64 {
65 SET_VALUE(open, "FriendlyAppName", "MuPDF");
66 SET_VALUE(command, "", command_str);
67 }
68 RegCloseKey(command);
69 RegCloseKey(open);
70 RegCloseKey(shell);
71 }
72 RegCloseKey(mupdf);
73
74 OPEN_KEY(classes, ".pdf", &dotpdf);
75 OPEN_KEY(classes, ".xps", &dotxps);
76 OPEN_KEY(classes, ".cbz", &dotcbz);
77 OPEN_KEY(classes, ".epub", &dotepub);
78 OPEN_KEY(classes, ".fb2", &dotfb2);
79 {
80 OPEN_KEY(dotpdf, "OpenWithProgids", &pdf_progids);
81 OPEN_KEY(dotxps, "OpenWithProgids", &xps_progids);
82 OPEN_KEY(dotcbz, "OpenWithProgids", &cbz_progids);
83 OPEN_KEY(dotepub, "OpenWithProgids", &epub_progids);
84 OPEN_KEY(dotfb2, "OpenWithProgids", &fb2_progids);
85 {
86 SET_VALUE(pdf_progids, "MuPDF", "");
87 SET_VALUE(xps_progids, "MuPDF", "");
88 SET_VALUE(cbz_progids, "MuPDF", "");
89 SET_VALUE(epub_progids, "MuPDF", "");
90 SET_VALUE(fb2_progids, "MuPDF", "");
91 }
92 RegCloseKey(pdf_progids);
93 RegCloseKey(xps_progids);
94 RegCloseKey(cbz_progids);
95 RegCloseKey(epub_progids);
96 RegCloseKey(fb2_progids);
97 }
98 RegCloseKey(dotpdf);
99 RegCloseKey(dotxps);
100 RegCloseKey(dotcbz);
101 RegCloseKey(dotepub);
102 RegCloseKey(dotfb2);
103 }
104 RegCloseKey(classes);
105 RegCloseKey(software);
106 }
107
108 #endif