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.

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