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.

293 lines
6.5 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. locinfo.c
  5. Abstract:
  6. Implements a tool that displays various localization details.
  7. Author:
  8. Jim Schmidt (jimschm) 26-Feb-1999
  9. Revision History:
  10. <full name> (<alias>) <date> <comments>
  11. --*/
  12. #include "pch.h"
  13. HANDLE g_hHeap;
  14. HINSTANCE g_hInst;
  15. BOOL WINAPI MigUtil_Entry (HINSTANCE, DWORD, PVOID);
  16. BOOL
  17. pCallEntryPoints (
  18. DWORD Reason
  19. )
  20. {
  21. HINSTANCE Instance;
  22. //
  23. // Simulate DllMain
  24. //
  25. Instance = g_hInst;
  26. //
  27. // Initialize the common libs
  28. //
  29. if (!MigUtil_Entry (Instance, Reason, NULL)) {
  30. return FALSE;
  31. }
  32. //
  33. // TODO: Add others here if needed (don't forget to prototype above)
  34. //
  35. return TRUE;
  36. }
  37. BOOL
  38. Init (
  39. VOID
  40. )
  41. {
  42. g_hHeap = GetProcessHeap();
  43. g_hInst = GetModuleHandle (NULL);
  44. return pCallEntryPoints (DLL_PROCESS_ATTACH);
  45. }
  46. VOID
  47. Terminate (
  48. VOID
  49. )
  50. {
  51. pCallEntryPoints (DLL_PROCESS_DETACH);
  52. }
  53. VOID
  54. HelpAndExit (
  55. VOID
  56. )
  57. {
  58. //
  59. // This routine is called whenever command line args are wrong
  60. //
  61. _ftprintf (
  62. stderr,
  63. TEXT("Command Line Syntax:\n\n")
  64. //
  65. // Describe command line syntax(es), indent 2 spaces
  66. //
  67. TEXT(" locinfo [-c] [-s] [-v]\n")
  68. TEXT("\nDescription:\n\n")
  69. TEXT(" locinfo displays details about localization.\n")
  70. TEXT("\nArguments:\n\n")
  71. TEXT(" -c Displays CP_ACP, CP_OEMCP and the default LCID\n")
  72. TEXT(" -s Displays startup info\n")
  73. TEXT(" -v Displays version info\n")
  74. );
  75. exit (1);
  76. }
  77. INT
  78. __cdecl
  79. _tmain (
  80. INT argc,
  81. PCTSTR argv[]
  82. )
  83. {
  84. INT i;
  85. PCTSTR FileArg;
  86. BOOL DisplayCp = FALSE;
  87. UINT Cp;
  88. LCID LcId;
  89. BOOL DisplayStartUpInfo = FALSE;
  90. BOOL DisplayVersionInfo = FALSE;
  91. STARTUPINFO si;
  92. //
  93. // Parse command line here
  94. //
  95. for (i = 1 ; i < argc ; i++) {
  96. if (argv[i][0] == TEXT('/') || argv[i][0] == TEXT('-')) {
  97. switch (_totlower (_tcsnextc (&argv[i][1]))) {
  98. case TEXT('c'):
  99. if (DisplayCp) {
  100. HelpAndExit();
  101. }
  102. DisplayCp = TRUE;
  103. break;
  104. case TEXT('s'):
  105. if (DisplayStartUpInfo) {
  106. HelpAndExit();
  107. }
  108. DisplayStartUpInfo = TRUE;
  109. break;
  110. case TEXT('v'):
  111. if (DisplayVersionInfo) {
  112. HelpAndExit();
  113. }
  114. DisplayVersionInfo = TRUE;
  115. break;
  116. case TEXT('f'):
  117. //
  118. // Sample option - /f:file
  119. //
  120. HelpAndExit(); // remove this
  121. if (argv[i][2] == TEXT(':')) {
  122. FileArg = &argv[i][3];
  123. } else if (i + 1 < argc) {
  124. FileArg = argv[++i];
  125. } else {
  126. HelpAndExit();
  127. }
  128. break;
  129. default:
  130. HelpAndExit();
  131. }
  132. } else {
  133. //
  134. // Parse other args that don't require / or -
  135. //
  136. // None
  137. HelpAndExit();
  138. }
  139. }
  140. //
  141. // Verify a valid option is specified, otherwise default to
  142. // DisplayCp
  143. //
  144. if (!DisplayCp && !DisplayStartUpInfo && !DisplayVersionInfo) {
  145. DisplayCp = TRUE;
  146. }
  147. if (DisplayCp && DisplayStartUpInfo) {
  148. HelpAndExit();
  149. }
  150. //
  151. // Begin processing
  152. //
  153. if (!Init()) {
  154. return 0;
  155. }
  156. //
  157. // Do work here
  158. //
  159. if (DisplayCp) {
  160. Cp = GetACP();
  161. _tprintf (TEXT("ANSI Code Page: %u (0x%04X)\n"), Cp, Cp);
  162. Cp = GetOEMCP();
  163. _tprintf (TEXT("OEM Code Page: %u (0x%04X)\n"), Cp, Cp);
  164. LcId = GetThreadLocale();
  165. _tprintf (TEXT("Thread Locale: %u (0x%04X)\n"), LcId, LcId);
  166. LcId = GetSystemDefaultLCID();
  167. _tprintf (TEXT("System Locale: %u (0x%04X)\n"), LcId, LcId);
  168. LcId = GetUserDefaultLCID();
  169. _tprintf (TEXT("User Locale: %u (0x%04X)\n"), LcId, LcId);
  170. _tprintf (TEXT("\n"));
  171. }
  172. if (DisplayStartUpInfo) {
  173. si.cb = sizeof (si);
  174. GetStartupInfo (&si);
  175. _tprintf (TEXT("lpDesktop %s\n"), si.lpDesktop);
  176. _tprintf (TEXT("lpTitle %s\n"), si.lpTitle);
  177. _tprintf (TEXT("dwX %u\n"), si.dwX);
  178. _tprintf (TEXT("dwY %u\n"), si.dwY);
  179. _tprintf (TEXT("dwXSize %u\n"), si.dwXSize);
  180. _tprintf (TEXT("dwYSize %u\n"), si.dwYSize);
  181. _tprintf (TEXT("dwXCountChars %u\n"), si.dwXCountChars);
  182. _tprintf (TEXT("dwYCountChars %u\n"), si.dwYCountChars);
  183. _tprintf (TEXT("dwFillAttribute %u\n"), si.dwFillAttribute);
  184. _tprintf (TEXT("dwFlags %u\n"), si.dwFlags);
  185. _tprintf (TEXT("wShowWindow %u\n"), si.wShowWindow);
  186. _tprintf (TEXT("hStdInput %u\n"), si.hStdInput);
  187. _tprintf (TEXT("hStdOutput %u\n"), si.hStdOutput);
  188. _tprintf (TEXT("hStdError %u\n"), si.hStdError);
  189. _tprintf (TEXT("\n"));
  190. Sleep (10000);
  191. }
  192. if (DisplayVersionInfo) {
  193. DWORD result;
  194. OSVERSIONINFO info;
  195. result = GetVersion ();
  196. _tprintf (TEXT("GetVersion result 0x%08X\n"), result);
  197. _tprintf (TEXT("OS major 0x%02X\n"), (DWORD)(LOBYTE(LOWORD(result))));
  198. _tprintf (TEXT("OS minor 0x%02X\n"), (DWORD)(HIBYTE(LOWORD(result))));
  199. _tprintf (TEXT("OS HI word 0x%04X\n"), (DWORD)(HIWORD(result)));
  200. info.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
  201. if (GetVersionEx (&info)) {
  202. _tprintf (TEXT("\nGetVersionEx result\n"));
  203. _tprintf (TEXT("OS major 0x%08X\n"), info.dwMajorVersion);
  204. _tprintf (TEXT("OS minor 0x%08X\n"), info.dwMinorVersion);
  205. _tprintf (TEXT("OS Build nr. 0x%08X\n"), info.dwBuildNumber);
  206. _tprintf (TEXT("OS Platform ID 0x%08X\n"), info.dwPlatformId);
  207. _tprintf (TEXT("OS CSD version %s\n"), info.szCSDVersion);
  208. }
  209. }
  210. //
  211. // End of processing
  212. //
  213. Terminate();
  214. return 0;
  215. }