2017-04-18 7 views
0

현재 사용중인 Windows OS가 활성화되어 있는지 사용자에게 알리는 C++ 함수를 작성하려고합니다.프로그래밍 방식으로 Windows가 C++로 활성화되었는지 확인

비슷한 질문이 Programmatically check if Windows 7 is activated인데이 대답에는 UID 인수가 필요합니다. 나는 사용자가 어떤 인수도 전혀 입력하지 않아야 함을 원하지 않는다.

프로그래밍 방식으로 Windows가 C++로 활성화되어 있는지 확인하려면 어떻게합니까?

답변

3
#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

+0

윌 윈도우의 모든 버전이 작동합니까? – antman1p

+0

@ antman1p No. 이것은 Vista +, Vista, Win7, Win8, Win8.1, Win10에서만 지원됩니다. Win10 및 Win8에서 테스트했습니다. Win7에서 테스트하지는 않았지만 100 % 확신 할 수 있습니다. – Brandon

관련 문제