Source code of Windows XP (NT5)
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.

157 lines
4.8 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows NT5.0
  4. // Copyright (C) Microsoft Corporation, 1997, 1998.
  5. //
  6. // File: O E M U P G . C P P
  7. //
  8. // Contents: Sample code for OEM network component upgrade DLL
  9. //
  10. // Notes:
  11. //
  12. //----------------------------------------------------------------------------
  13. #include "pch.h"
  14. #pragma hdrstop
  15. // oemupgex.h is a part of the DDK
  16. #include "oemupgex.h"
  17. HMODULE g_hNetupgrdDll;
  18. NetUpgradeAddSectionPrototype g_pfnNuAddSection;
  19. NetUpgradeAddLineToSectionPrototype g_pfnNuAddLineToSection;
  20. VENDORINFO g_viOem =
  21. {
  22. L"Foo Inc.",
  23. L"(123) 456 7890",
  24. L"http://www.foo.com",
  25. L"Please visit our website for further information"
  26. };
  27. EXTERN_C LONG __stdcall
  28. PreUpgradeInitialize(IN PCWSTR szWorkingDir,
  29. IN NetUpgradeInfo* pNetUpgradeInfo,
  30. OUT VENDORINFO* pviVendorInfo,
  31. OUT DWORD* pdwFlags,
  32. OUT NetUpgradeData* pNetUpgradeData)
  33. {
  34. DWORD dwError=ERROR_SUCCESS;
  35. // get function address of the two exported functions
  36. // for writing into the answerfile
  37. //
  38. g_hNetupgrdDll = GetModuleHandle(L"netupgrd.dll");
  39. if (g_hNetupgrdDll)
  40. {
  41. g_pfnNuAddSection =
  42. (NetUpgradeAddSectionPrototype)
  43. GetProcAddress(g_hNetupgrdDll, c_szNetUpgradeAddSection);
  44. g_pfnNuAddLineToSection =
  45. (NetUpgradeAddLineToSectionPrototype)
  46. GetProcAddress(g_hNetupgrdDll, c_szNetUpgradeAddLineToSection);
  47. if (!g_pfnNuAddSection || !g_pfnNuAddLineToSection)
  48. {
  49. // this should never occur
  50. //
  51. dwError = ERROR_CALL_NOT_IMPLEMENTED;
  52. }
  53. }
  54. return dwError;
  55. }
  56. EXTERN_C LONG __stdcall
  57. DoPreUpgradeProcessing(IN HWND hParentWindow,
  58. IN HKEY hkeyParams,
  59. IN PCWSTR szPreNT5InfId,
  60. IN PCWSTR szPreNT5Instance,
  61. IN PCWSTR szNT5InfId,
  62. IN PCWSTR szSectionName,
  63. OUT VENDORINFO* pviVendorInfo,
  64. OUT DWORD* pdwFlags,
  65. IN LPVOID pvReserved)
  66. {
  67. DWORD dwError=ERROR_SUCCESS;
  68. WCHAR szTempSection[256];
  69. WCHAR szTempLine[256];
  70. // set the flag so that we will get loaded during GUI setup
  71. *pdwFlags |= NUA_LOAD_POST_UPGRADE;
  72. if (g_pfnNuAddSection && g_pfnNuAddLineToSection)
  73. {
  74. // add the top level section
  75. //
  76. g_pfnNuAddSection(szSectionName);
  77. // add the mandatory key InfToRunBeforeInstall
  78. //
  79. // note: here it is assumed that the OEM also supplies a file foocopy.inf
  80. // and that it has a section named foo.CopyFiles
  81. //
  82. swprintf(szTempLine, L"%s=foocopy.inf,foo.CopyFiles",
  83. c_szInfToRunBeforeInstall);
  84. g_pfnNuAddLineToSection(szSectionName, szTempLine);
  85. // add the optional key InfToRunAfterInstall
  86. //
  87. swprintf(szTempLine, L"%s=,%s.SectionToRun",
  88. c_szInfToRunAfterInstall, szSectionName);
  89. g_pfnNuAddLineToSection(szSectionName, szTempLine);
  90. // now add the section that should be run
  91. //
  92. swprintf(szTempSection, L"%s.SectionToRun", szSectionName);
  93. g_pfnNuAddSection(szTempSection);
  94. // add the AddReg key
  95. //
  96. swprintf(szTempLine, L"AddReg=%s.AddReg", szTempSection);
  97. g_pfnNuAddLineToSection(szTempSection, szTempLine);
  98. // now add the AddReg section
  99. //
  100. swprintf(szTempSection, L"%s.SectionToRun.AddReg",
  101. szSectionName);
  102. g_pfnNuAddSection(szTempSection);
  103. // finally add registry operations to this section
  104. //
  105. swprintf(szTempLine, L"HKR,0\\0,IsdnPhoneNumber,0,\"%s\"",
  106. L"111-2222");
  107. g_pfnNuAddLineToSection(szTempSection, szTempLine);
  108. swprintf(szTempLine, L"HKR,0\\0,IsdnPhoneNumber,0,\"%s\"",
  109. L"333-4444");
  110. g_pfnNuAddLineToSection(szTempSection, szTempLine);
  111. }
  112. return dwError;
  113. }
  114. EXTERN_C LONG __stdcall
  115. PostUpgradeInitialize(IN PCWSTR szWorkingDir,
  116. IN NetUpgradeInfo* pNetUpgradeInfo,
  117. OUT VENDORINFO* pviVendorInfo,
  118. OUT LPVOID pvReserved)
  119. {
  120. return ERROR_SUCCESS;
  121. }
  122. EXTERN_C LONG __stdcall
  123. DoPostUpgradeProcessing(IN HWND hParentWindow,
  124. IN HKEY hkeyParams,
  125. IN PCWSTR szPreNT5Instance,
  126. IN PCWSTR szNT5InfId,
  127. IN HINF hinfAnswerFile,
  128. IN PCWSTR szSectionName,
  129. OUT VENDORINFO* pviVendorInfo,
  130. IN LPVOID pvReserved)
  131. {
  132. return ERROR_SUCCESS;
  133. }