Windows Explorer New Menu

Gliddador

Member
Joined
Jan 22, 2023
Messages
22
Programming Experience
5-10
In an application I wrote formerly, a very small application, there was code for modifying the Windows Registry, so that the Explorer's New Menu might also be modified. This code worked well on Windows 10, but now, on Windows 11, the changes in the new menu are only seen after logging back into Windows. I did change the code a little, but it remains so sufficiently unmodified that it should still do the same thing.

I know I didn't share my code yet, but by reading this post can you see any problem, so that I must add code to notify the shell? Also, how would I do that?

Thank you.
 

Gliddador

Member
Joined
Jan 22, 2023
Messages
22
Programming Experience
5-10
Okay, I think I have to call SHChangeNotify in my code, but I don't want to copy DLL P/Invoke declarations into my code. Is there a good Win32 API NuGet Package that has the SHChangeNotify function and other declarations it needs? Even though I know I probably need to call SHChangeNotify, I'm not sure which event code to pass as an argument. I originally thought it should be the one about file type associations but now I'm not sure.
 

JohnH

C# Forum Moderator
Staff member
Joined
Apr 23, 2011
Messages
1,560
Location
Norway
Programming Experience
10+

Gliddador

Member
Joined
Jan 22, 2023
Messages
22
Programming Experience
5-10
Thank you, but now I have another problem. I somehow changed my code so that the ShellNew thing didn't work properly when creating a new file. I could fix it, but that's not the main problem. The problem is this: I am ignorant of the many ways the registry can be configured to do things with file associations. I was not aware of the OpenWithProgIds key until I saw it in the registry.

I need to display the file type in a listview. I also need someway of combining the data from the current user and the local machine. I'm not sure if using ClassesRoot would work.

Does anyone know a source for learning how to configure the Windows registry? Thank you.

One more question? Is it ShellNew/Open/Command or ShellNew/Command/Open? Thank you.
 
Last edited:

Gliddador

Member
Joined
Jan 22, 2023
Messages
22
Programming Experience
5-10
I ordered a book pertaining to the Windows Registry, and intend to finish developing my program after I have gotten the necessary knowledge.
 
Last edited:

Skydiver

Staff member
Joined
Apr 6, 2019
Messages
6,705
Location
Chesapeake, VA
Programming Experience
10+
Usually the information about the registry is documented in Microsoft's documentation. The hard part maybe that there isn't always a unifying piece of documentation that explains how things are inter-related. Often people just figure it out on their own. Hopefully that book that you ordered provides the needed higher level view.
 

Gliddador

Member
Joined
Jan 22, 2023
Messages
22
Programming Experience
5-10
After testing my code again, I realized that it still worked properly. However, I do not know how to retrieve a file type based on its extension from the Windows Registry. Can anyone provide this information, or a resource with this information? Thank you.

Also, I had added a call to SHChangeNotify to my code several days ago, and that caused the Explorer's file new menu to update whenever changes to it are made by my application.
 

Skydiver

Staff member
Joined
Apr 6, 2019
Messages
6,705
Location
Chesapeake, VA
Programming Experience
10+
Also, I had added a call to SHChangeNotify to my code several days ago, and that caused the Explorer's file new menu to update whenever changes to it are made by my application.

Sounds like the API is working by design.
 

Skydiver

Staff member
Joined
Apr 6, 2019
Messages
6,705
Location
Chesapeake, VA
Programming Experience
10+
However, I do not know how to retrieve a file type based on its extension from the Windows Registry. Can anyone provide this information, or a resource with this information?

So you've been hacking on the registry but you don't know what you are doing while hacking on the registry. Sounds awfully dangerous to me.
 

Skydiver

Staff member
Joined
Apr 6, 2019
Messages
6,705
Location
Chesapeake, VA
Programming Experience
10+

Gliddador

Member
Joined
Jan 22, 2023
Messages
22
Programming Experience
5-10
I don't have a full understanding of the registry, but I know enough to do certain things, while avoiding making changes that are dangerous. Also, if I were doing anything serious, I would make a backup of the registry, which I ought to do every time that I change it.

I think that I will add a feature in my program to reverse whatever change is made. So far I haven't made any serious mistakes with Registry .NET API, but I have to be careful. I will make sure I back up the registry before each test, and that the program works perfectly before I publish it or make my repository public.

Thank you for the link. I think that, if accurate, it is helpful.
 

Gliddador

Member
Joined
Jan 22, 2023
Messages
22
Programming Experience
5-10
You are correct, however, that I should not be messing with the Windows Registry, while having an insufficient understanding. So I will depend on documentation, which is what I've been looking for.
 

Gliddador

Member
Joined
Jan 22, 2023
Messages
22
Programming Experience
5-10
Also, I put that I have 5 to 10 years of experience programming, but I have gotten very rusty since I worked for a small startup, and have not done that much coding since then, which was about 10 years ago. I worked there for four years, and had been programming for several years (interrupted years) before that. So even though I am not very skilled now, I provided an honest answer.

To be honest, I was never as good as someone working for Microsoft, or as someone with a computer science background, but I was good enough to do my job, and only had trouble with it when my mental health issues started to flare up again.
 
Last edited:

Gliddador

Member
Joined
Jan 22, 2023
Messages
22
Programming Experience
5-10
Sorry for posting so many replies. That Stackoverflow answer did not give me the information required for getting the name of a file type from its extension.

Thanks for trying to help but I need more thorough documentation. I will try to find it in MSDN. I have not explored the registry for the answer. I prefer to depend on documentation.
 

Skydiver

Staff member
Joined
Apr 6, 2019
Messages
6,705
Location
Chesapeake, VA
Programming Experience
10+
Just going off of memory from Craig Brockschmidt's "Inside OLE" book which covered registering OLE objects specifically, but also dealt a little bit about file extension mappings. Forgive any possible inaccuracies. I last read that book back in the mid 90's. In general, every file extension will map to a ProgID. Every ProgID will have as its default value the friendly display name of that type.
 

Gliddador

Member
Joined
Jan 22, 2023
Messages
22
Programming Experience
5-10
Thank you for your answer, Skydiver, but when I look at the registry, I see that many ProgIDs, which I assume are the keys pointed to by the default values of file extension keys, have no friendly display name.
 

Skydiver

Staff member
Joined
Apr 6, 2019
Messages
6,705
Location
Chesapeake, VA
Programming Experience
10+
Traditionally, it would look something like this:
1676135069692.png


1676135151361.png


.docxml's default value is the ProgID wordxmlfile. Looking at the ProgID wordxmlfile, we find that it's display name is "Microsoft Word XML Document".

With the Win10 style entries we see something like this:
1676135304432.png

Nothing set for the default value, so let's look at the "OpenWithProgids":
1676135346960.png

And follow that trail:
1676135442712.png
 
Top Bottom