Control Panel Applet I Wrote

  • (2 Pages)
  • +
  • 1
  • 2

19 Replies - 623 Views - Last Post: 05 October 2019 - 08:29 PM

#1 garbus   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 41
  • Joined: 18-June 17

Control Panel Applet I Wrote

Posted 02 October 2019 - 03:43 PM

I wrote a simple control panel applet allowing you to modify the new file context menu on Windows. You can add new file types to the new menu, modify existing ones, and remove existing ones.

You just have to run it for the first time and check "Display this editor in the control panel", and after that it should show up in the control panel.

What do you think?

Is This A Good Question/Topic? 0
  • +

Replies To: Control Panel Applet I Wrote

#2 Skydiver   User is online

  • Code herder
  • member icon

Reputation: 7093
  • View blog
  • Posts: 24,102
  • Joined: 05-May 12

Re: Control Panel Applet I Wrote

Posted 02 October 2019 - 06:58 PM

Moving to Share Your Project...
Was This Post Helpful? 0
  • +
  • -

#3 garbus   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 41
  • Joined: 18-June 17

Re: Control Panel Applet I Wrote

Posted 03 October 2019 - 06:30 PM

I put the code on sourceforge with an installer so you don't have to compile the code:

New File Context Menu Editor

This post has been edited by garbus: 03 October 2019 - 06:31 PM

Was This Post Helpful? 0
  • +
  • -

#4 Skydiver   User is online

  • Code herder
  • member icon

Reputation: 7093
  • View blog
  • Posts: 24,102
  • Joined: 05-May 12

Re: Control Panel Applet I Wrote

Posted 04 October 2019 - 08:18 AM

Out of curiosity, why do you use substring method to get the first character? Why not just use the string character indexer?
Was This Post Helpful? 0
  • +
  • -

#5 garbus   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 41
  • Joined: 18-June 17

Re: Control Panel Applet I Wrote

Posted 04 October 2019 - 12:59 PM

simply because I didn't think of that

This post has been edited by Skydiver: 04 October 2019 - 02:42 PM
Reason for edit:: Removed unnecessary quote. No need to quote the post above yours.

Was This Post Helpful? 0
  • +
  • -

#6 Skydiver   User is online

  • Code herder
  • member icon

Reputation: 7093
  • View blog
  • Posts: 24,102
  • Joined: 05-May 12

Re: Control Panel Applet I Wrote

Posted 04 October 2019 - 02:47 PM

Since you are using an installer now, do you really need to run as admin for the cases when you are updating the HKCR keys?

With your original code when you first posted, I could see the need for running as admin since you needed to update HKLM to install the control panel applet. Now that you have an installer that presumably runs as admin while installing, your can have the installer do the appropriate registry key changes to do the control panel install/uninstall.

To quote from the documentation:

Quote

To change the settings for the interactive user, store the changes under HKEY_CURRENT_USER\Software\Classes rather than HKEY_CLASSES_ROOT.

Unless I'm mistaken, the current user should have enough rights to update HKCU\Software\Classes without running as admin.
Was This Post Helpful? 0
  • +
  • -

#7 garbus   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 41
  • Joined: 18-June 17

Re: Control Panel Applet I Wrote

Posted 04 October 2019 - 06:02 PM

HKCU\Software\Classes doesn't contain all the file types registered on the system. And the user won't be able to remove or edit file types from the new menu that were already there before they modified it at all.

This post has been edited by Skydiver: 04 October 2019 - 07:20 PM
Reason for edit:: Removed unnecessary quote. No need to quote the post above yours.

Was This Post Helpful? 0
  • +
  • -

#8 Skydiver   User is online

  • Code herder
  • member icon

Reputation: 7093
  • View blog
  • Posts: 24,102
  • Joined: 05-May 12

Re: Control Panel Applet I Wrote

Posted 04 October 2019 - 07:25 PM

There is no need to quote the post above yours. Just use the big Reply button or the Fast Reply area.

That is correct. It doesn't contain everything. That is because of the merged view that the OS creates by merging that per-user key values with the machine key values. Values in the per-user overrides the values found in the per machine.
Was This Post Helpful? 0
  • +
  • -

#9 garbus   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 41
  • Joined: 18-June 17

Re: Control Panel Applet I Wrote

Posted 05 October 2019 - 07:46 AM

Okay, I updated the applet to use HKEY_CURRENT_USER\Software\Classes. Also, I removed the calls to substring and replaced them with calls to the string indexer.
Was This Post Helpful? 0
  • +
  • -

#10 Skydiver   User is online

  • Code herder
  • member icon

Reputation: 7093
  • View blog
  • Posts: 24,102
  • Joined: 05-May 12

Re: Control Panel Applet I Wrote

Posted 05 October 2019 - 07:54 AM

Your control panel registration code still exists. That requires running as administrator.
Was This Post Helpful? 0
  • +
  • -

#11 garbus   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 41
  • Joined: 18-June 17

Re: Control Panel Applet I Wrote

Posted 05 October 2019 - 08:54 AM

That gets executed by the installer.
Was This Post Helpful? 0
  • +
  • -

#12 Skydiver   User is online

  • Code herder
  • member icon

Reputation: 7093
  • View blog
  • Posts: 24,102
  • Joined: 05-May 12

Re: Control Panel Applet I Wrote

Posted 05 October 2019 - 09:09 AM

Then why does it have to be protected by the single instance mutex? If there's a currently running instance, then uninstalling will fail. Or if there is a currently running instance, and you try to install an upgrade, that install will fail as well.

Also, why this a method instead of just a constant string:
        const string ControlPanelNamespaceId = "{20DCE34F-2141-42D5-802E-5E328899586B}";

        private static string GetControlPanelNamespaceKeyName()
        {
            return @"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel\Namespace\" +
                ControlPanelNamespaceId;
        }


Was This Post Helpful? 0
  • +
  • -

#13 garbus   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 41
  • Joined: 18-June 17

Re: Control Panel Applet I Wrote

Posted 05 October 2019 - 09:26 AM

Okay, I fixed it.
Was This Post Helpful? 0
  • +
  • -

#14 Skydiver   User is online

  • Code herder
  • member icon

Reputation: 7093
  • View blog
  • Posts: 24,102
  • Joined: 05-May 12

Re: Control Panel Applet I Wrote

Posted 05 October 2019 - 09:49 AM

What are these magic numbers here:
            if (cmbAction.SelectedIndex < 1)
            {
                cmbAction.SelectedIndex = 0;
            }



and here?
            txtPath.Enabled = cmbAction.SelectedIndex > 0;

            if (cmbAction.SelectedIndex == 2)



Why is MainForm.cs using the GUI as the data model? Why are the View, Model, and Controller all intermingled with each other?
Was This Post Helpful? 0
  • +
  • -

#15 garbus   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 41
  • Joined: 18-June 17

Re: Control Panel Applet I Wrote

Posted 05 October 2019 - 09:57 AM

Okay, fixed it. (Not the model, view, controller thing. I did not fix that.)

What do you mean about the model, view, controller?

I'm familiar with MVC and MVVM but why do I need that here?

This post has been edited by garbus: 05 October 2019 - 10:00 AM

Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2