I would like to obtain a list, using C#, of all progis's on my computer. I know I can scan the registry, something like this:
var regClis = Registry.ClassesRoot.OpenSubKey("CLSID");
var progs = new List<string>();
foreach (var clsid in regClis.GetSubKeyNames()) {
var regClsidKey = regClis.OpenSubKey(clsid);
var ProgID = regClsidKey.OpenSubKey("ProgID");
var regPath = regClsidKey.OpenSubKey("InprocServer32");
if (regPath == null)
regPath = regClsidKey.OpenSubKey("LocalServer32");
if (regPath != null && ProgID != null) {
var pid = ProgID.GetValue("");
var filePath = regPath.GetValue("");
progs.Add(pid + " -> " + filePath);
regPath.Close();
}
regClsidKey.Close();
}
The code is from this blog.
Does anyone know if there's a simpler way? Also, as far as I understand how this works, the code above would probaly only give me in-process com. What if I need out of process progids as well?
Thanks in advance
This will give you all registered ProgIDs, local or remote (as out-of-proc, not another machine, of course). Besides, the code is just enumerating the registry key, it is simple already.
If the question is 'is there a specific API for this', there is not one provided by MS. Quite possibly there is some third-party implementation which basically does the same thing as this code.