简体   繁体   中英

Get MS Office ApplicationID programmatically

My Microsoft Office 2013 installation has an ApplicationId value that I need to get programmatically (it is 0ff1ce15-a989-479d-af46-f275c6370663 . For MS Office 2010 installation it is 59a52881-a989-479d-af46-f275c6370663 ) So eventually I have 2 questions:

  1. Are these values identical for same MS office versions on different PCs?
  2. How to programmatically get these values for 2007-2016 in C++? (through Automation, or some other way).

Thank you in advance.

was looking for another answer so thought I would reply, yes they are the same on different machines though each office version will have it's own unique ID as you know.

I was using c# and used a WMI query to look for the details in the class SoftwareLicensingProduct though it is also found in OfficeSoftwareProtectionProduct below is my query

"SELECT ID, ApplicationId, PartialProductKey, Name, ProductKeyID FROM SoftwareLicensingProduct  WHERE ApplicationId = '" + sApplicationId+"' AND PartialProductKey <> NULL"

I have code that runs before that identifies the version of office on the workstation and the result of that query will set the relevant ApplicationID

            if (sVersion == "2013")
        {
             sApplicationId = "Office 15 Application ID";

        }
        else if (sVersion == "2016")
        {
             sApplicationId = "Office 16 Application ID";
        }

To get the version of Office that is on the box you could either parse the registry or not sure if you can do this in c++ I launched Word hidden and retrieved the application version then used a Case statement

            switch (appVersion.Version.ToString())
        {
            case "15.0":
                sVersion = "2013";
                break;
            case "16.0":
                sVersion = "2016";
                break;
            case "14.0":
                sVersion = "2010";
                break;
            default:
                sVersion = "No Version detected!";
                break;
        }

I know I could probably automate this further and pull out the ApplicationID from the WMI query but not got round to that yet.

Not sure if this helps?

Barry

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM