GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Simplified code. · ReClassNET/ReClass.NET@569a590

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • ReClass.NET/Native
    • NativeMethods.Windows.cs
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎ReClass.NET/Native/NativeMethods.Windows.cs‎

Copy file name to clipboardExpand all lines: ReClass.NET/Native/NativeMethods.Windows.cs
+9-62Lines changed: 9 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -177,85 +177,32 @@ public bool RegisterExtension(string fileExtension, string extensionId, string a
177177
{
178178
var classesRoot = Registry.ClassesRoot;
179179

180-
try
181-
{
182-
classesRoot.CreateSubKey(fileExtension);
183-
}
184-
catch (Exception)
185-
{
186-
187-
}
188-
using (var fileExtensionKey = classesRoot.OpenSubKey(fileExtension, true))
180+
using (var fileExtensionKey = classesRoot.CreateSubKey(fileExtension))
189181
{
190182
fileExtensionKey?.SetValue(string.Empty, extensionId, RegistryValueKind.String);
191183
}
192184

193-
try
194-
{
195-
classesRoot.CreateSubKey(extensionId);
196-
}
197-
catch (Exception)
198-
{
199-
200-
}
201-
using (var extensionInfoKey = classesRoot.OpenSubKey(extensionId, true))
185+
using (var extensionInfoKey = classesRoot.CreateSubKey(extensionId))
202186
{
203187
extensionInfoKey?.SetValue(string.Empty, applicationName, RegistryValueKind.String);
204188

205-
try
206-
{
207-
extensionInfoKey?.CreateSubKey("DefaultIcon");
208-
}
209-
catch (Exception)
210-
{
211-
212-
}
213-
214-
using (var icon = extensionInfoKey?.OpenSubKey("DefaultIcon", true))
189+
using (var icon = extensionInfoKey?.CreateSubKey("DefaultIcon"))
215190
{
216191
if (applicationPath.IndexOfAny(new[] { ' ', '\t' }) < 0)
217192
{
218-
icon?.SetValue(string.Empty, applicationPath + ",0", RegistryValueKind.String);
219-
}
220-
else
221-
{
222-
icon?.SetValue(string.Empty, "\"" + applicationPath + "\",0", RegistryValueKind.String);
193+
applicationPath = "\"" + applicationPath + "\"";
223194
}
224-
}
225195

226-
try
227-
{
228-
extensionInfoKey?.CreateSubKey("shell");
229-
}
230-
catch (Exception)
231-
{
196+
icon?.SetValue(string.Empty, "\"" + applicationPath + "\",0", RegistryValueKind.String);
232197
}
233-
using (var shellKey = extensionInfoKey?.OpenSubKey("shell", true))
234-
{
235-
try
236-
{
237-
shellKey?.CreateSubKey("open");
238-
}
239-
catch (Exception)
240-
{
241-
242-
}
243198

244-
using (var openKey = shellKey?.OpenSubKey("open", true))
199+
using (var shellKey = extensionInfoKey?.CreateSubKey("shell"))
200+
{
201+
using (var openKey = shellKey?.CreateSubKey("open"))
245202
{
246-
247203
openKey?.SetValue(string.Empty, $"&Open with {applicationName}", RegistryValueKind.String);
248204

249-
try
250-
{
251-
openKey?.CreateSubKey("command");
252-
}
253-
catch (Exception)
254-
{
255-
256-
}
257-
258-
using (var commandKey = openKey?.OpenSubKey("command", true))
205+
using (var commandKey = openKey?.CreateSubKey("command"))
259206
{
260207
commandKey?.SetValue(string.Empty, $"\"{applicationPath}\" \"%1\"", RegistryValueKind.String);
261208
}

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.