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.

97 lines
3.9 KiB

  1. #include <stdio.h>
  2. #include <windows.h>
  3. void __cdecl main(char* argc[])
  4. {
  5. CHAR szSavedCalendarType [5];
  6. CHAR chTemp[256];
  7. CHAR szTemp[256];
  8. SYSTEMTIME theTime;
  9. int i = 0;
  10. DWORD dwError;
  11. TCHAR szError[1024];
  12. for (;;)
  13. {
  14. int iLocalCalType;
  15. if (GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_ICALENDARTYPE, szSavedCalendarType, sizeof(szSavedCalendarType)-1))
  16. {
  17. iLocalCalType = CAL_GREGORIAN_US;
  18. printf(" Calendartype: %s\n", szSavedCalendarType);
  19. wsprintf(chTemp, "%d", iLocalCalType);
  20. if (!SetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_ICALENDARTYPE, chTemp))
  21. {
  22. dwError = GetLastError();
  23. wsprintf( szError,
  24. "Case 4 - Trying to SET the user calendar to \"%s\", Current Active codepage: %d and the return Error Code: %d, count:%d",
  25. chTemp,
  26. GetACP(),
  27. dwError,
  28. i);
  29. MessageBeep(0);
  30. MessageBox(NULL, szError, "SetLocaleInfo() Error", MB_OK | MB_ICONEXCLAMATION);
  31. }
  32. if (!GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_ICALENDARTYPE, szTemp, sizeof(szTemp)-1))
  33. {
  34. dwError = GetLastError();
  35. wsprintf( szError,
  36. "Case 5 - Trying to GET back the user calendar \"%s\", Current Active codepage: %d and the return Error Code: %d, count: %d",
  37. chTemp,
  38. GetACP(),
  39. dwError,
  40. i);
  41. MessageBeep(0);
  42. MessageBox(NULL, szError, "GetLocaleInfo() Error", MB_OK | MB_ICONEXCLAMATION);
  43. }
  44. printf(" Calendartype: %s\n", szTemp);
  45. GetLocalTime(&theTime); // just a time to pass into the Win32 API:
  46. if (!SetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_ICALENDARTYPE, szSavedCalendarType))
  47. {
  48. dwError = GetLastError();
  49. wsprintf( szError,
  50. "Case 2 - Trying to SET back the user calendar to \"%s\", Current Active codepage: %d and the return Error Code: %d, count: %d",
  51. szSavedCalendarType,
  52. GetACP(),
  53. dwError,
  54. i);
  55. MessageBeep(0);
  56. MessageBox(NULL, szError, "SetLocaleInfo() Error", MB_OK | MB_ICONEXCLAMATION);
  57. }
  58. else
  59. {
  60. if (!GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_ICALENDARTYPE, szTemp, sizeof(szTemp)-1))
  61. {
  62. dwError = GetLastError();
  63. wsprintf( szError,
  64. "Case 3 - Trying to GET back the user calendar \"%s\", Current Active codepage: %d and the return Error Code: %d, count: %d",
  65. szSavedCalendarType,
  66. GetACP(),
  67. dwError,
  68. i);
  69. MessageBeep(0);
  70. MessageBox(NULL, szError, "Error in GetLocaleInfo", MB_OK | MB_ICONEXCLAMATION);
  71. }
  72. printf(" Calendartype: %s\n", szTemp);
  73. }
  74. }
  75. else
  76. {
  77. dwError = GetLastError();
  78. wsprintf( szError,
  79. "Case 1 - Trying to GET back the user calendar \"%s\", Current Active codepage: %d and the return Error Code: %d, count: %d",
  80. szSavedCalendarType,
  81. GetACP(),
  82. dwError,
  83. i);
  84. MessageBeep(0);
  85. MessageBox(NULL, szError, "Error in GetLocaleInfo", MB_OK | MB_ICONEXCLAMATION);
  86. }
  87. printf(".\n");
  88. i++;
  89. }
  90. }