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.

140 lines
3.6 KiB

  1. /****************************************************************************\
  2. HOMENET.C / Factory Mode (FACTORY.EXE)
  3. Microsoft Confidential
  4. Copyright (c) Microsoft Corporation 2001
  5. All rights reserved
  6. Source file for Factory that contains the home net state functions.
  7. 05/2001 - Jason Cohen (JCOHEN)
  8. Added this new source file for factory for configuring the home
  9. networking settings.
  10. \****************************************************************************/
  11. //
  12. // Include File(s):
  13. //
  14. #include "factoryp.h"
  15. //
  16. // Internal Define(s):
  17. //
  18. #define FILE_HOMENET_DLL _T("HNETCFG.DLL")
  19. #define FUNC_HOMENET "WinBomConfigureHomeNet"
  20. //
  21. // Internal Type Definition(s):
  22. //
  23. /****************************************************************************\
  24. BOOL // Returns TRUE if the settings were successfully
  25. // read and saved to the system. Otherwise
  26. // returns FALSE to indicate something failed.
  27. WinBomConfigureHomeNet( // Reads home networking settings from the
  28. // specified unattend file and saves those in
  29. // current system that is already setup and
  30. // running.
  31. LPCWSTR lpszUnattend, // Points to a string buffer which contains the
  32. // full path to the unattend file (winbom.ini in
  33. // this case) with all the home network settings.
  34. LPCWSTR lpszSection // Points to a string buffer which contains the
  35. // name of the section which contains all the home
  36. // network settings in the unattend file specified
  37. // above.
  38. );
  39. \****************************************************************************/
  40. typedef BOOL (WINAPI * WINBOMCONFIGUREHOMENET)
  41. (
  42. LPCWSTR lpszUnattend,
  43. LPCWSTR lpszSection
  44. );
  45. //
  46. // Internal Global(s):
  47. //
  48. //
  49. // Internal Function Prototype(s):
  50. //
  51. //
  52. // External Function(s):
  53. //
  54. BOOL HomeNet(LPSTATEDATA lpStateData)
  55. {
  56. BOOL bRet = FALSE;
  57. HINSTANCE hDll;
  58. WINBOMCONFIGUREHOMENET pFunc;
  59. HRESULT hr;
  60. // Load the function from the external dll and call it.
  61. //
  62. if ( hDll = LoadLibrary(FILE_HOMENET_DLL) )
  63. {
  64. // Need to init the COM library.
  65. //
  66. hr = CoInitialize(NULL);
  67. if ( SUCCEEDED(hr) )
  68. {
  69. // Now call the function.
  70. //
  71. if ( pFunc = (WINBOMCONFIGUREHOMENET) GetProcAddress(hDll, FUNC_HOMENET) )
  72. {
  73. bRet = pFunc(lpStateData->lpszWinBOMPath, INI_SEC_HOMENET);
  74. }
  75. #ifdef DBG
  76. else
  77. {
  78. FacLogFileStr(3, _T("DEBUG: GetProcAddress(\"WinBomConfigureHomeNet\") failed. GLE=%d"), GetLastError());
  79. }
  80. #endif
  81. CoUninitialize();
  82. }
  83. #ifdef DBG
  84. else
  85. {
  86. FacLogFileStr(3, _T("DEBUG: HomeNet()::CoInitialize() failed. HR=%8.8X"), hr);
  87. }
  88. #endif
  89. FreeLibrary(hDll);
  90. }
  91. #ifdef DBG
  92. else
  93. {
  94. FacLogFileStr(3, _T("DEBUG: LoadLibrary(\"%s\") failed. GLE=%d"), FILE_HOMENET_DLL, GetLastError());
  95. }
  96. #endif
  97. return bRet;
  98. }
  99. BOOL DisplayHomeNet(LPSTATEDATA lpStateData)
  100. {
  101. return IniSettingExists(lpStateData->lpszWinBOMPath, INI_SEC_HOMENET, NULL, NULL);
  102. }
  103. //
  104. // Internal Function(s):
  105. //