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.

149 lines
3.0 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // File: main.cpp
  4. //
  5. // Description:
  6. //
  7. // Copyright (c) 2000 Microsoft Corp.
  8. //
  9. //////////////////////////////////////////////////////////////////////////////
  10. // App Includes
  11. #include "precomp.h"
  12. #include "main.h"
  13. #include <commctrl.h>
  14. ///////////////////////////
  15. // GVAR_LOCAL
  16. //
  17. // Global Variable
  18. //
  19. static struct GVAR_LOCAL
  20. {
  21. HINSTANCE hInstance;
  22. } GVAR_LOCAL =
  23. {
  24. NULL
  25. };
  26. ////////////////////////// Function Prototypes ////////////////////////////////
  27. static bool InitApp(HINSTANCE hInstance);
  28. static bool TermApp();
  29. //////////////////////////////
  30. // WinMain
  31. //
  32. int APIENTRY WinMain(HINSTANCE hInstance,
  33. HINSTANCE hPrevInstance,
  34. LPSTR lpCmdLine,
  35. int nCmdShow)
  36. {
  37. HWND hwndCfgDlg = NULL;
  38. bool bSuccess = false;
  39. bool bDone = false;
  40. int iReturnValue = 0;
  41. MSG msg;
  42. // initialize our application
  43. bSuccess = InitApp(hInstance);
  44. if (bSuccess)
  45. {
  46. // create our config dialog, which is our main dialog
  47. hwndCfgDlg = CfgDlg::Create(nCmdShow);
  48. if (hwndCfgDlg == NULL)
  49. {
  50. iReturnValue = -1;
  51. bSuccess = false;
  52. }
  53. }
  54. if (bSuccess)
  55. {
  56. while (::GetMessage(&msg, NULL, 0, 0))
  57. {
  58. ::TranslateMessage(&msg);
  59. ::DispatchMessage(&msg);
  60. }
  61. }
  62. TermApp();
  63. return iReturnValue;
  64. }
  65. //////////////////////////////
  66. // InitApp
  67. //
  68. static bool InitApp(HINSTANCE hInstance)
  69. {
  70. HRESULT hr = S_OK;
  71. bool bReturn = true;
  72. INITCOMMONCONTROLSEX CommonControls = {0};
  73. BOOL bSuccess = FALSE;
  74. //
  75. // initialize the common control library
  76. //
  77. CommonControls.dwSize = sizeof(CommonControls);
  78. CommonControls.dwICC = ICC_BAR_CLASSES | ICC_WIN95_CLASSES;
  79. bSuccess = InitCommonControlsEx(&CommonControls);
  80. if (bSuccess)
  81. {
  82. DBG_TRC(("Successfully initialized Common Controls"));
  83. }
  84. else
  85. {
  86. DBG_TRC(("Failed to Init Common Controls, LastError = %lu",
  87. GetLastError()));
  88. }
  89. //
  90. // Initialize COM
  91. //
  92. if (SUCCEEDED(hr))
  93. {
  94. // we are apartment threaded because the UPnP device host API
  95. // claims it has some problems in a free threaded model.
  96. //
  97. hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
  98. }
  99. //
  100. // Initialize our Util Library
  101. //
  102. if (SUCCEEDED(hr))
  103. {
  104. hr = Util::Init(hInstance);
  105. }
  106. //
  107. // Initialize our Config Dialog module
  108. //
  109. if (SUCCEEDED(hr))
  110. {
  111. hr = CfgDlg::Init(hInstance);
  112. }
  113. return bReturn;
  114. }
  115. //////////////////////////////
  116. // TermApp
  117. //
  118. static bool TermApp()
  119. {
  120. // shutdown the Config Dialog Module
  121. CfgDlg::Term();
  122. // shutdown the Util Module.
  123. Util::Term();
  124. return true;
  125. }