3

I am developing a desktop application, using C#, to track the applications which are running in windows. Is that any unique number for every application which is installed in windows?

I can get the handle number but the handle number is changed while reopening the application.

I need the unique identifier for every application installed in windows.

Matthew Haugen
  • 12,916
  • 5
  • 38
  • 54
  • No, there isn't. You can make educated guesses using things like the MSI package GUID (assuming it was installed with MSI) or pathnames or hashing the exe contents but there's nothing guaranteed to be both unique and stable. – Michael Edenfield Aug 07 '14 at 23:26
  • 3
    What problem are you trying to solve? – Kit Aug 07 '14 at 23:35
  • 4
    I guess the most reliable ID you'll be able to get is the exe file path. Don't try to map that to a number though. – Lucas Trzesniewski Aug 07 '14 at 23:44

1 Answers1

0

Use the WMI System.Management API. I think you want the IdentifyingNumber which will give you a GUID for the product.

    ManagementObjectSearcher mos = new ManagementObjectSearcher("SELECT * FROM Win32_Product");
    foreach (ManagementObject mo in mos.Get())
    {
        Console.WriteLine(mo["Name"]);
        foreach (PropertyData prop in mo.Properties)
        {
            Console.WriteLine("{0}: {1}", prop.Name, prop.Value);
        }
    }
Mick
  • 6,527
  • 4
  • 52
  • 67