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.

139 lines
3.5 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1999.
  5. //
  6. // File: G U I S E T U P . C P P
  7. //
  8. // Contents: Routines that are only executed during GUI setup.
  9. //
  10. // Notes:
  11. //
  12. // Author: shaunco 19 Feb 1999
  13. //
  14. //----------------------------------------------------------------------------
  15. #include <pch.h>
  16. #pragma hdrstop
  17. #include "guisetup.h"
  18. #include "nceh.h"
  19. #include "ncreg.h"
  20. #include "ncsetup.h"
  21. #include "netcomm.h"
  22. #include "netsetup.h"
  23. VOID
  24. ExcludeMarkedServicesForSetup (
  25. IN const CComponent* pComponent,
  26. IN OUT CPszArray* pServiceNames)
  27. {
  28. HRESULT hr;
  29. HKEY hkeyInstance;
  30. HKEY hkeyNdi;
  31. PWSTR pmszExclude;
  32. CPszArray::iterator iter;
  33. PCWSTR pszServiceName;
  34. hr = pComponent->HrOpenInstanceKey (KEY_READ, &hkeyInstance, NULL, NULL);
  35. if (S_OK == hr)
  36. {
  37. hr = HrRegOpenKeyEx (hkeyInstance, L"Ndi", KEY_READ, &hkeyNdi);
  38. if (S_OK == hr)
  39. {
  40. hr = HrRegQueryMultiSzWithAlloc (
  41. hkeyNdi,
  42. L"ExcludeSetupStartServices",
  43. &pmszExclude);
  44. if (S_OK == hr)
  45. {
  46. iter = pServiceNames->begin();
  47. while (iter != pServiceNames->end())
  48. {
  49. pszServiceName = *iter;
  50. Assert (pszServiceName);
  51. if (FIsSzInMultiSzSafe (pszServiceName, pmszExclude))
  52. {
  53. pServiceNames->erase (iter);
  54. }
  55. else
  56. {
  57. iter++;
  58. }
  59. }
  60. MemFree (pmszExclude);
  61. }
  62. RegCloseKey (hkeyNdi);
  63. }
  64. RegCloseKey (hkeyInstance);
  65. }
  66. }
  67. VOID
  68. ProcessAdapterAnswerFileIfExists (
  69. IN const CComponent* pComponent)
  70. {
  71. HDEVINFO hdi;
  72. SP_DEVINFO_DATA deid;
  73. HRESULT hr;
  74. Assert (pComponent);
  75. hr = pComponent->HrOpenDeviceInfo (&hdi, &deid);
  76. if (S_OK == hr)
  77. {
  78. PWSTR pszAnswerFile = NULL;
  79. PWSTR pszAnswerSections = NULL;
  80. TraceTag (ttidNetcfgBase, "Calling Netsetup for Install parameters");
  81. NC_TRY
  82. {
  83. // Get the Network install params for the adapter
  84. //
  85. hr = HrGetAnswerFileParametersForNetCard (hdi, &deid,
  86. pComponent->Ext.PszBindName(),
  87. &pComponent->m_InstanceGuid,
  88. &pszAnswerFile, &pszAnswerSections);
  89. }
  90. NC_CATCH_ALL
  91. {
  92. hr = E_UNEXPECTED;
  93. }
  94. if (S_OK == hr)
  95. {
  96. #ifdef ENABLETRACE
  97. if (pszAnswerFile)
  98. {
  99. TraceTag (ttidNetcfgBase, "Answerfile %S given for adapter",
  100. pszAnswerFile);
  101. }
  102. if (pszAnswerSections)
  103. {
  104. TraceTag (ttidNetcfgBase, "Section %S given for adapter",
  105. pszAnswerSections);
  106. }
  107. #endif // ENABLETRACE
  108. if (ProcessAnswerFile (pszAnswerFile, pszAnswerSections, hdi,
  109. &deid))
  110. {
  111. hr = HrSetupDiSendPropertyChangeNotification (hdi, &deid,
  112. DICS_PROPCHANGE, DICS_FLAG_GLOBAL, 0);
  113. }
  114. }
  115. // Cleanup up if necessary
  116. CoTaskMemFree (pszAnswerFile);
  117. CoTaskMemFree (pszAnswerSections);
  118. SetupDiDestroyDeviceInfoList (hdi);
  119. }
  120. }