[C] Checking license status

Discussion in 'Mixed Languages' started by Pr3acher, Nov 11, 2012.

  1. Pr3acher

    Pr3acher MDL Member

    Aug 24, 2012
    143
    48
    10
    That's exactly what i was going to do at the begining, but i have to find exacly the words like "Licensed" or "Grace period" in the output for then returning em to an edit... it'd be boring. Plus i want something else than always dealing with slmgr
     
  2. Muerto

    Muerto MDL Debugger

    Mar 7, 2012
    1,858
    2,115
    60
    I think you'll find it'll only output as 0 or 1. You have to convert that data.
     
  3. Josh Cell

    Josh Cell MDL Developer

    Jan 8, 2011
    3,515
    7,171
    120
    Slmgr /xpr showns the product activation.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. Alphawaves

    Alphawaves Super Moderator/Developer
    Staff Member

    Aug 11, 2008
    6,222
    22,281
    210
    #24 Alphawaves, Nov 17, 2012
    Last edited by a moderator: Apr 20, 2017
    C#:
    Code:
    bool Licensed = false;
                try
                {
                    foreach (ManagementObject Obj in new ManagementObjectSearcher("root\\CIMV2", "SELECT LicenseStatus FROM SoftwareLicensingProduct WHERE LicenseStatus = 1").Get())
                    {
                        Licensed = true;
                    }
                }
                catch (ManagementException) { Licensed = false; }
     
  5. Muerto

    Muerto MDL Debugger

    Mar 7, 2012
    1,858
    2,115
    60
    Here is how to check the License Status with Microsoft C++, compiled with VS2010.

    It uses WMI but I've edited it and it takes less than a second to check.

    Download the source here.
     
  6. Pr3acher

    Pr3acher MDL Member

    Aug 24, 2012
    143
    48
    10
    I wanna thank you all for your help, i'm using the slmgr trick since i dont have time to learn more about WMI, but holidays (Christmas holidays) are comming soon and i'll have time to get back to programming, cuz as i said u i'm getting extremly busy at that moment and i can't do anything like coding and learning stuff.
     
  7. Muerto

    Muerto MDL Debugger

    Mar 7, 2012
    1,858
    2,115
    60
    Well remember, you need to know anything, feel free to message me.

    Enjoy your Christmas :D
     
  8. Alphawaves

    Alphawaves Super Moderator/Developer
    Staff Member

    Aug 11, 2008
    6,222
    22,281
    210
    #28 Alphawaves, Dec 3, 2012
    Last edited: Dec 3, 2012
    :D
    The better solution for anything you need >> post here for our coders/developers to help you :D:)
    (I like the open source code help we give here @ MDL as it also helps others):hug2:
     
  9. Pr3acher

    Pr3acher MDL Member

    Aug 24, 2012
    143
    48
    10
    Hey, ok i've been learning WMI and i notice it's really cool stuff. I can access several low level infos with this, thx all of you. i'm now learning C++ since i can't use Qt with C, besides i'm fed up with WinAPI which is hard to handle and lots of code for little things, nah...