@@ -130,25 +130,46 @@ bool FileAssociation::Ext::set(winstl::reg_key_w const& root, Classes const& c)
130
130
return false ;
131
131
}
132
132
133
+ bool FileAssociation::Ext::has_owl (winstl::reg_key_w& root) const
134
+ {
135
+ try {
136
+ return root.open_sub_key (ext_.c_str ()).has_value (L" Application" );
137
+ } catch (winstl::registry_exception const & ) { }
138
+
139
+ return false ;
140
+ }
141
+
142
+ bool FileAssociation::Ext::set_owl (winstl::reg_key_w& root)
143
+ {
144
+ try {
145
+ return root.open_sub_key (ext_.c_str ()).delete_value (L" Application" );
146
+ } catch (winstl::registry_exception const & ) { }
147
+
148
+ return false ;
149
+ }
133
150
134
151
FileAssociation::FileAssociation (fs::path const & ydwe_path)
135
152
: root_(HKEY_CURRENT_USER, L" Software\\ Classes" )
153
+ , root2_(HKEY_CURRENT_USER, L" Software\\ Microsoft\\ Windows\\ CurrentVersion\\ Explorer\\ FileExts" )
136
154
, classes_(L" YDWEMap" )
137
155
, ext_w3x_(L" .w3x" )
138
156
, ext_w3m_(L" .w3m" )
139
157
, icon_path_(ydwe_path.parent_path() / L"bin" / L"logo.ico")
140
158
, command_(L" \" " + ydwe_path.wstring() + L"\" -loadfile \"%1\"")
141
- {
142
- }
159
+ { }
143
160
144
161
bool FileAssociation::has_w3x ()
145
162
{
146
- return classes_.has (root_, command_) && ext_w3x_.has (root_, classes_);
163
+ return classes_.has (root_, command_)
164
+ && ext_w3x_.has (root_, classes_)
165
+ && ext_w3x_.has_owl (root2_);
147
166
}
148
167
149
168
bool FileAssociation::has_w3m ()
150
169
{
151
- return classes_.has (root_, command_) && ext_w3m_.has (root_, classes_);
170
+ return classes_.has (root_, command_)
171
+ && ext_w3m_.has (root_, classes_)
172
+ && ext_w3m_.has_owl (root2_);
152
173
}
153
174
154
175
bool FileAssociation::remove_w3x ()
@@ -175,12 +196,12 @@ void FileAssociation::remove()
175
196
176
197
bool FileAssociation::set_w3x ()
177
198
{
178
- return ext_w3x_.set (root_, classes_);
199
+ return ext_w3x_.set (root_, classes_) && ext_w3x_. set_owl (root2_) ;
179
200
}
180
201
181
202
bool FileAssociation::set_w3m ()
182
203
{
183
- return ext_w3m_.set (root_, classes_);
204
+ return ext_w3m_.set (root_, classes_) && ext_w3m_. set_owl (root2_) ;
184
205
}
185
206
186
207
bool FileAssociation::set_classes ()
0 commit comments