c++ - 以编程方式检查 Windows 是否已使用 C++ 激活

标签 c++ windows authentication activation

我正在尝试编写一个 C++ 函数,它会告诉用户他们当前使用的 Windows 操作系统是否已激活。

我发现了类似的问题Programmatically check if Windows 7 is activated ,但这个答案需要 UID 参数。我根本不希望用户必须输入任何参数。

如何以编程方式检查 Windows 是否已使用 C++ 激活?

最佳答案

#define _WIN32_WINNT 0x600

#include <iostream>
#include <windows.h>
#include <slpublic.h>


/*'
From: C:/Windows/System32/SLMGR.vbs


' Copyright (c) Microsoft Corporation. All rights reserved.
'
' Windows Software Licensing Management Tool.
'
' Script Name: slmgr.vbs
'
' WMI class names
private const ServiceClass                            = "SoftwareLicensingService"
private const ProductClass                            = "SoftwareLicensingProduct"
private const TkaLicenseClass                         = "SoftwareLicensingTokenActivationLicense"
private const WindowsAppId                            = "55c92734-d682-4d71-983e-d6ec3f16059f"
*/


/** Use the WindowsAppId above to check if Windows OS itself is Genuine. **/
bool isGenuineWindows()
{
    //WindowsAppId
    unsigned char uuid_bytes[] = {0x35, 0x35, 0x63, 0x39, 0x32, 0x37, 0x33, 0x34, 0x2d, 0x64, 0x36,
                                0x38, 0x32, 0x2d, 0x34, 0x64, 0x37, 0x31, 0x2d, 0x39, 0x38, 0x33,
                                0x65, 0x2d, 0x64, 0x36, 0x65, 0x63, 0x33, 0x66, 0x31, 0x36, 0x30,
                                0x35, 0x39, 0x66};

    GUID uuid;
    SL_GENUINE_STATE state;

    UuidFromStringA(uuid_bytes, &uuid);
    SLIsGenuineLocal(&uuid, &state, nullptr);
    return state == SL_GEN_STATE_IS_GENUINE;
}

int main()
{
    std::cout<<isGenuineWindows();
    return 0;
}

链接:librpcrt4.alibslwga.a

关于c++ - 以编程方式检查 Windows 是否已使用 C++ 激活,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43483541/

相关文章:

C++ 映射值在运行时没有改变,我做错了什么?

java - 最好使用哪种无限循环

python - “caching_sha2_password”插件在 Windows 上失败

c# - x64 计算机上 x86 LARGEADDRESSAWARE 程序的内核模式内存大小?

iPhone/iOS Facebook SDK - 您可以在应用程序中登录并保留登录凭据吗?

authentication - 在 Rails 4 中测试 HTTP 摘要式身份验证

c++ - VC9下SQLite3的麻烦

c++ - 我们是否有增强的 std::remove_if STL 函数来保留将要删除的元素

c++ - 访问其他程序并改变其行为(主要是关于游戏的非官方多人模式)

java - 使用构造函数创建帐户并登录