Search code examples
c#.netwinapishellexecute

How to open a file/protocol with a specific (not default) class


There are several questions on StackOverflow along the lines of "How do I use ShellExecute/ShellExecuteEx in C#?", to which the answer is pretty much: "Use System.Diagnostics.Process". However, what I want to do is open a file or URL using a non default handler.

I can accomplish this using ShellExecuteEx by just passing in the class name and setting the SEE_MASK_CLASSNAME flag, and I have this working using DllImport.

What I want to know is: is there a way of doing this in C# without importing from the DLL? Is there a way of passing this kind of information to Process, or is the way I have it working the "right" way of doing it?


Solution

  • There is no equivalent way of doing it in .NET. Your way of handling (using ShellExecuteEx) it is right way.