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.

151 lines
3.1 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. eZippy Main
  5. Abstract:
  6. Entrypoint for eZippy.
  7. Author:
  8. Marc Reyhner 8/28/00
  9. --*/
  10. #include "stdafx.h"
  11. #include "eZippy.h"
  12. #include "ZippyWindow.h"
  13. #include "TraceManager.h"
  14. #include "resource.h"
  15. // instantiation of the g_hInstance variable
  16. HINSTANCE g_hInstance = NULL;
  17. int
  18. WINAPI WinMain(
  19. IN HINSTANCE hInstance,
  20. IN HINSTANCE hPrevInstance,
  21. IN LPSTR lpCmdLine,
  22. IN int nCmdShow
  23. )
  24. /*++
  25. Routine Description:
  26. This sets up the trace manager and the zippy window then does
  27. the event loop.
  28. Arguments:
  29. See win32 WinMain docs
  30. Return value:
  31. 0 - Success
  32. Non zero - some error
  33. --*/
  34. {
  35. INITCOMMONCONTROLSEX controlStruct;
  36. MSG msg;
  37. DWORD dwResult;
  38. CZippyWindow mainWindow;
  39. CTraceManager tracer;
  40. LPTSTR lpstrCmdLine;
  41. HACCEL hAccel;
  42. g_hInstance = hInstance;
  43. controlStruct.dwSize = sizeof(controlStruct);
  44. controlStruct.dwICC = ICC_BAR_CLASSES;
  45. InitCommonControlsEx(&controlStruct);
  46. CTraceManager::_InitTraceManager();
  47. dwResult = mainWindow.Create(&tracer);
  48. if (lpCmdLine && lpCmdLine[0]) {
  49. // kill any leading and trailing " marks
  50. lpstrCmdLine = GetCommandLine();
  51. if (lpstrCmdLine[0] == '"') {
  52. lpstrCmdLine++;
  53. lpstrCmdLine[_tcslen(lpstrCmdLine)-1] = 0;
  54. }
  55. mainWindow.LoadConfFile(lpstrCmdLine);
  56. }
  57. tracer.StartListenThread(&mainWindow);
  58. if (dwResult) {
  59. return dwResult;
  60. }
  61. hAccel = LoadAccelerators(hInstance,MAKEINTRESOURCE(IDR_ACCELERATOR));
  62. while (0 < GetMessage(&msg,NULL,0,0)) {
  63. if (mainWindow.IsDialogMessage(&msg)) {
  64. // if it is a dialog message we are done
  65. // processing this message
  66. continue;
  67. }
  68. if (!mainWindow.TranslateAccelerator(hAccel,&msg)) {
  69. TranslateMessage(&msg);
  70. DispatchMessage(&msg);
  71. }
  72. }
  73. CTraceManager::_CleanupTraceManager();
  74. return 0;
  75. }
  76. INT
  77. LoadStringSimple(
  78. IN UINT uID,
  79. OUT LPTSTR lpBuffer
  80. )
  81. /*++
  82. Routine Description:
  83. This will load the given string from the applications string table. If
  84. it is longer than MAX_STR_LEN it is truncated. lpBuffer should be at least
  85. MAX_STR_LEN characters long. If the string does not exist we return 0
  86. and set the buffer to IDS_STRINGMISSING, if that failes then we set it to the
  87. hard coded STR_RES_MISSING.
  88. Arguments:
  89. uID - Id of the resource to load.
  90. lpBuffer - Buffer of MAX_STR_LEN to hold the string
  91. Return value:
  92. 0 - String resource could not be loaded.
  93. postive integer - length of the string loaded.
  94. --*/
  95. {
  96. INT length;
  97. length = LoadString(g_hInstance,uID,lpBuffer,MAX_STR_LEN);
  98. if (length == 0) {
  99. length = LoadString(g_hInstance,IDS_STRINGMISSING,lpBuffer,MAX_STR_LEN);
  100. if (length == 0) {
  101. _tcscpy(lpBuffer,_T(""));
  102. }
  103. length = 0;
  104. }
  105. return length;
  106. }