none
how to check my window os is activated or not in c#? RRS feed

  • Question

  • Hi all
    i want to check my operating system in activated or not using c# code.
    Please help
    TIA 

    sumitk

    Friday, November 17, 2017 7:03 AM

All replies

  • With WMI or SL APIs.

    For example with WMI :

    try
    {
        ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM SoftwareLicensingProduct WHERE PartialProductKey <> null AND ApplicationId='55c92734-d682-4d71-983e-d6ec3f16059f' AND LicenseIsAddon=False");
        foreach (ManagementObject queryObj in searcher.Get())
        {                      
            Console.WriteLine("LicenseStatus: {0} - ProductKeyID: {1}", queryObj["LicenseStatus"], queryObj["ProductKeyID"]);
        }
    }
    catch (ManagementException me)
    {
        MessageBox.Show("WMI Error: " + me.Message);
    }

    Friday, November 17, 2017 8:56 AM

  • Hi Sumitk.cdac,

    You can use  The Software Licensing API (function: SLIsGenuineLocal (Checks whether the specified application is a genuine Windows installation)), The Minimum supported client is Windows Vista.


    You can refer the following link for getting detailed information.

    Determine Genuine Windows Installation in C#:
    https://stackoverflow.com/questions/1552392/determine-genuine-windows-installation-in-c-sharp


    Best Regards,

    Yong Lu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, November 20, 2017 5:52 AM
    Moderator
  • thanks Yong Lu,
    i want to check status of windows XP also.

    Please share any link or code if you have


    sumitk

    Monday, November 20, 2017 6:11 AM
  • hi ,

    the parameter which you are providing with Application id is unique or what?

    what i have to do for passing this parameter for my OS?


    sumitk

    Monday, November 20, 2017 6:13 AM
  • the parameter which you are providing with Application id is unique or what?

    what i have to do for passing this parameter for my OS?

    Yes, it is a constant

    "55c92734-d682-4d71-983e-d6ec3f16059f" = WINDOWS_SLID

    Monday, November 20, 2017 7:14 AM