Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
1.9 KiB

  1. #include "setupp.h"
  2. #include <activation.h>
  3. #include <LAModes.h>
  4. #include <licdll.h>
  5. #pragma hdrstop
  6. extern "C"
  7. BOOL Activationrequired(VOID)
  8. {
  9. DWORD Status = ERROR_SUCCESS;
  10. HRESULT hr;
  11. DWORD WPADaysLeft = -1;
  12. DWORD EvalDaysLeftDontCare = 0;
  13. ICOMLicenseAgent* pLicenseAgent;
  14. BOOL bActivcationRequired = TRUE;
  15. SetupDebugPrint( L"Setup: Activationrequired" );
  16. hr = CoInitialize(NULL);
  17. if (SUCCEEDED(hr))
  18. {
  19. //CoCreate LicenseAgent
  20. if(SUCCEEDED(hr = CoCreateInstance(__uuidof(COMLicenseAgent),
  21. NULL,
  22. CLSCTX_INPROC_SERVER,
  23. __uuidof(ICOMLicenseAgent),
  24. (LPVOID*)&pLicenseAgent)))
  25. {
  26. pLicenseAgent->Initialize(
  27. WINDOWSBPC,
  28. LA_MODE_ONLINE_CH,
  29. NULL,
  30. &Status
  31. );
  32. if ( Status == ERROR_SUCCESS ) {
  33. hr = pLicenseAgent->GetExpirationInfo(
  34. &WPADaysLeft,
  35. &EvalDaysLeftDontCare
  36. );
  37. if (SUCCEEDED(hr))
  38. {
  39. bActivcationRequired = (WPADaysLeft != INT_MAX);
  40. }
  41. else
  42. {
  43. SetupDebugPrint2( L"Setup: LicenseAgent->GetExpirationInfo hr =0x%lx WPADaysLeft=%d", hr, WPADaysLeft);
  44. }
  45. }
  46. else
  47. {
  48. SetupDebugPrint1( L"Setup: LicenseAgent->Initialize status = %d", Status);
  49. }
  50. pLicenseAgent->Release();
  51. pLicenseAgent = NULL;
  52. }
  53. else
  54. {
  55. SetupDebugPrint1( L"Setup: CoCreateInstance failed. hr=0x%lx", hr );
  56. }
  57. CoUninitialize();
  58. }
  59. return bActivcationRequired;
  60. }