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.

78 lines
2.1 KiB

  1. /****************************************************************************\
  2. PID.C / Factory Mode (FACTORY.EXE)
  3. Microsoft Confidential
  4. Copyright (c) Microsoft Corporation 2002
  5. All rights reserved
  6. Source file for Factory that contains the Optional Components state
  7. functions.
  8. 04/2002 - Stephen Lodwick (STELO)
  9. Added this new source file for factory to be able to repopulate product
  10. id and digital id if one is supplied in winbom.ini
  11. \****************************************************************************/
  12. //
  13. // Include File(s):
  14. //
  15. #include "factoryp.h"
  16. #include <licdll.h>
  17. #include <licdll_i.c>
  18. //
  19. // Internal Define(s):
  20. //
  21. //
  22. // External Function(s):
  23. //
  24. BOOL PidPopulate(LPSTATEDATA lpStateData)
  25. {
  26. BOOL bRet = TRUE;
  27. TCHAR szBuffer[50] = NULLSTR;
  28. ICOMLicenseAgent* pLicenseAgent;
  29. // Check to see if the ProductKey key exists in the winbom
  30. //
  31. if ( GetPrivateProfileString( INI_SEC_WBOM_SETTINGS, INI_KEY_WBOM_PRODKEY, NULLSTR, szBuffer, AS(szBuffer), lpStateData->lpszWinBOMPath) &&
  32. szBuffer[0] )
  33. {
  34. FacLogFileStr(3, _T("Attempting to reset Product Key: %s\n"), szBuffer);
  35. if ( (SUCCEEDED(CoInitialize(NULL))) &&
  36. (SUCCEEDED(CoCreateInstance(&CLSID_COMLicenseAgent, NULL, CLSCTX_INPROC_SERVER, &IID_ICOMLicenseAgent, (LPVOID *) &pLicenseAgent)))
  37. )
  38. {
  39. if ( SUCCEEDED(pLicenseAgent->lpVtbl->SetProductKey(pLicenseAgent, szBuffer)) )
  40. {
  41. FacLogFileStr(3, _T("Successfully reset Product Key: %s\n"), szBuffer);
  42. }
  43. else
  44. {
  45. FacLogFileStr(3, _T("Failed to reset Product Key: %s\n"), szBuffer);
  46. bRet = FALSE;
  47. }
  48. pLicenseAgent->lpVtbl->Release(pLicenseAgent);
  49. }
  50. else
  51. {
  52. FacLogFileStr(3, _T("Failed to reset Product Key: %s\n"), szBuffer);
  53. bRet = FALSE;
  54. }
  55. CoUninitialize();
  56. }
  57. return bRet;
  58. }