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.

175 lines
5.3 KiB

  1. //--------------------------------------------------------------------
  2. // w32tm - implementation
  3. // Copyright (C) Microsoft Corporation, 1999
  4. //
  5. // Created by: Louis Thomas (louisth), 9-8-99
  6. //
  7. // Command line utility
  8. //
  9. #include "pch.h" // precompiled headers
  10. //####################################################################
  11. // module private
  12. HINSTANCE g_hThisModule = NULL;
  13. //--------------------------------------------------------------------
  14. MODULEPRIVATE void PrintHelp(void) {
  15. UINT idsText[] = {
  16. IDS_W32TM_GENERALHELP_LINE1,
  17. IDS_W32TM_GENERALHELP_LINE2,
  18. IDS_W32TM_GENERALHELP_LINE3,
  19. IDS_W32TM_GENERALHELP_LINE4,
  20. IDS_W32TM_GENERALHELP_LINE5,
  21. IDS_W32TM_GENERALHELP_LINE6,
  22. IDS_W32TM_GENERALHELP_LINE7
  23. };
  24. for (int n=0; n<ARRAYSIZE(idsText); n++)
  25. LocalizedWPrintf(idsText[n]);
  26. PrintHelpTimeMonitor();
  27. PrintHelpOtherCmds();
  28. }
  29. //####################################################################
  30. // module public
  31. //--------------------------------------------------------------------
  32. // If we are running from the command line, business as usual.
  33. // If we are running under SCM, this is our control dispatcher thread
  34. // and we need to hook up to the SCM asap.
  35. extern "C" int WINAPI WinMain
  36. (HINSTANCE hinstExe,
  37. HINSTANCE hinstExePrev,
  38. LPSTR pszCommandLine,
  39. int nCommandShow)
  40. {
  41. g_hThisModule = hinstExe;
  42. HRESULT hr;
  43. CmdArgs caArgs;
  44. int nArgs = 0;
  45. WCHAR **rgwszArgs = NULL;
  46. hr = InitializeConsoleOutput();
  47. _JumpIfError(hr, error, "InitializeConsoleOutput");
  48. rgwszArgs = CommandLineToArgvW(GetCommandLineW(), &nArgs);
  49. if (nArgs < 0 || NULL == rgwszArgs) {
  50. _JumpError(HRESULT_FROM_WIN32(GetLastError()), error, "GetCommandLineW");
  51. }
  52. // must be cleaned up
  53. DebugWPrintf0(L""); // force init of debug window
  54. // analyze args
  55. caArgs.nArgs=nArgs;
  56. caArgs.nNextArg=1;
  57. caArgs.rgwszArgs=rgwszArgs;
  58. // check for help command
  59. if (true==CheckNextArg(&caArgs, L"?", NULL) || caArgs.nNextArg==caArgs.nArgs) {
  60. PrintHelp();
  61. // check for service command
  62. } else if (true==CheckNextArg(&caArgs, L"service", NULL)) {
  63. hr=VerifyAllArgsUsed(&caArgs);
  64. _JumpIfError(hr, error, "VerifyAllArgsUsed");
  65. hr=RunAsService();
  66. _JumpIfError(hr, error, "RunAsService");
  67. // check for test command
  68. } else if (true==CheckNextArg(&caArgs, L"testservice", NULL)) {
  69. hr=VerifyAllArgsUsed(&caArgs);
  70. _JumpIfError(hr, error, "VerifyAllArgsUsed");
  71. hr=RunAsTestService();
  72. _JumpIfError(hr, error, "RunAsTestService");
  73. // check for monitor command
  74. } else if (true==CheckNextArg(&caArgs, L"monitor", NULL)) {
  75. hr=TimeMonitor(&caArgs);
  76. _JumpIfError(hr, error, "TimeMonitor");
  77. // check for register command
  78. } else if (true==CheckNextArg(&caArgs, L"register", NULL)) {
  79. hr=VerifyAllArgsUsed(&caArgs);
  80. _JumpIfError(hr, error, "VerifyAllArgsUsed");
  81. hr=RegisterDll();
  82. _JumpIfError(hr, error, "RegisterDll");
  83. // check for unregister command
  84. } else if (true==CheckNextArg(&caArgs, L"unregister", NULL)) {
  85. hr=VerifyAllArgsUsed(&caArgs);
  86. _JumpIfError(hr, error, "VerifyAllArgsUsed");
  87. hr=UnregisterDll();
  88. _JumpIfError(hr, error, "UnregisterDll");
  89. // check for sysexpr command
  90. } else if (true==CheckNextArg(&caArgs, L"sysexpr", NULL)) {
  91. hr=SysExpr(&caArgs);
  92. _JumpIfError(hr, error, "SysExpr");
  93. // check for ntte command
  94. } else if (true==CheckNextArg(&caArgs, L"ntte", NULL)) {
  95. hr=PrintNtte(&caArgs);
  96. _JumpIfError(hr, error, "PrintNtte");
  97. // check for ntte command
  98. } else if (true==CheckNextArg(&caArgs, L"ntpte", NULL)) {
  99. hr=PrintNtpte(&caArgs);
  100. _JumpIfError(hr, error, "PrintNtpte");
  101. // check for resync command
  102. } else if (true==CheckNextArg(&caArgs, L"resync", NULL)) {
  103. hr=ResyncCommand(&caArgs);
  104. _JumpIfError(hr, error, "ResyncCommand");
  105. // check for stripchart command
  106. } else if (true==CheckNextArg(&caArgs, L"stripchart", NULL)) {
  107. hr=Stripchart(&caArgs);
  108. _JumpIfError(hr, error, "Stripchart");
  109. // check for config command
  110. } else if (true==CheckNextArg(&caArgs, L"config", NULL)
  111. || true==CheckNextArg(&caArgs, L"configure", NULL)) {
  112. hr=Config(&caArgs);
  113. _JumpIfError(hr, error, "Config");
  114. // check for testif command
  115. } else if (true==CheckNextArg(&caArgs, L"testif", NULL)) {
  116. hr=TestInterface(&caArgs);
  117. _JumpIfError(hr, error, "TestInterface");
  118. // check for tz command
  119. } else if (true==CheckNextArg(&caArgs, L"tz", NULL)) {
  120. hr=ShowTimeZone(&caArgs);
  121. _JumpIfError(hr, error, "ShowTimeZone");
  122. // dump configuration information in registry:
  123. } else if (true==CheckNextArg(&caArgs, L"dumpreg", NULL)) {
  124. hr=DumpReg(&caArgs);
  125. _JumpIfError(hr, error, "DumpReg");
  126. // command is unknown
  127. } else {
  128. wprintf(L"The command %s is unknown.\n", caArgs.rgwszArgs[caArgs.nNextArg]);
  129. hr=E_INVALIDARG;
  130. _JumpError(hr, error, "(command line processing)");
  131. }
  132. hr=S_OK;
  133. error:
  134. DebugWPrintfTerminate();
  135. return hr;
  136. }
  137. void __cdecl SeTransFunc(unsigned int u, EXCEPTION_POINTERS* pExp) {
  138. throw SeException(u);
  139. }