0

How can I get the ProgID of any application given the name of the application in C#?

  <Association Identifier="http" ProgId="ChromeHTML" ApplicationName="Google Chrome" />

In the example "Google Chrome" has a ProgId of "ChromeHTML" How can I retrieve this value in .Net?

It looks like the OLE-COM Library Object Viewer has the info in it, if there is a .Net way to query that? Or any other straight forward way?

Or can I get the CLSID given an applicationName? then use

[DllImport("ole32.dll")]
        static extern int ProgIDFromCLSID([In] ref Guid clsid,
           [MarshalAs(UnmanagedType.LPWStr)] out string lplpszProgID);

What I am attempting to do is add file associations programmtically given either and applicationName or an exe path

nlstack01
  • 789
  • 2
  • 7
  • 30
  • Possible duplicate of [C# Get progID from COM object](https://stackoverflow.com/questions/1253368/c-sharp-get-progid-from-com-object) – 41686d6564 stands w. Palestine Oct 03 '17 at 15:28
  • @AhmedAbdelhameed I looked at this example it does not seem complete for my purposes – nlstack01 Oct 03 '17 at 15:31
  • There is no correlation, it is just something you have to know. Using Regedit.exe to search through HKCR generally helps you find it. Changing the user's default browser is something you need to leave up to the user, they care. – Hans Passant Oct 03 '17 at 15:37
  • Yes, Hans is right *(of course :D)*. So, regardless of Chrome, if you're targeting random applications, how would you know if your executable has a COM interface? And what are you planning to do with the `ProgID`? Anyway, if you're sure that the executable you're after has a COM interface, [this](http://blogs.artinsoft.net/Mrojas/archive/2007/10/23/Get-GUIDsCLSIDs-from-Exe-dll-ocx-tlb-etc.aspx) might help. – 41686d6564 stands w. Palestine Oct 03 '17 at 16:44
  • @AhmedAbdelhameed What I am attempting to do is add file associations programmtically given either and applicationName or an exe path. In order to do this I need the ProgId – nlstack01 Oct 03 '17 at 16:56
  • I'm not an expert in this particular area, and maybe someone could correct me, but my understanding is when adding a file association in the registry, the ProgID can be any *unique* string because if the program doesn't support COM, there will be no existing ProgID value, hence you can use any string as long as you don't use the same string for other applications. – 41686d6564 stands w. Palestine Oct 03 '17 at 17:27
  • @AhmedAbdelhameed if this is the case why bother with that information in xml that is used to create file associations? So what your saying is all you need it the applicationName (shown in the xml above) and file associations works? – nlstack01 Oct 03 '17 at 17:46

0 Answers0