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.

72 lines
2.7 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. wsprintf(chTemp, "%d", iLocalCalType);
  19. SetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_ICALENDARTYPE, chTemp);
  20. GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_ICALENDARTYPE, szTemp, sizeof(szTemp)-1);
  21. GetLocalTime(&theTime); // just a time to pass into the Win32 API:
  22. if (!SetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_ICALENDARTYPE, szSavedCalendarType))
  23. {
  24. dwError = GetLastError();
  25. wsprintf( szError,
  26. "Case 2 - Trying to SET back the user calendar to \"%s\", Current Active codepage: %d and the return Error Code: %d, count: %d",
  27. szSavedCalendarType,
  28. GetACP(),
  29. dwError,
  30. i);
  31. MessageBeep(0);
  32. MessageBox(NULL, szError, "SetLocaleInfo() Error", MB_OK | MB_ICONEXCLAMATION);
  33. }
  34. else
  35. {
  36. if (!GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_ICALENDARTYPE, szTemp, sizeof(szTemp)-1))
  37. {
  38. dwError = GetLastError();
  39. wsprintf( szError,
  40. "Case 3 - Trying to GET back the user calendar \"%s\", Current Active codepage: %d and the return Error Code: %d, count: %d",
  41. szSavedCalendarType,
  42. GetACP(),
  43. dwError,
  44. i);
  45. MessageBeep(0);
  46. MessageBox(NULL, szError, "Error in GetLocaleInfo", MB_OK | MB_ICONEXCLAMATION);
  47. }
  48. }
  49. }
  50. else
  51. {
  52. dwError = GetLastError();
  53. wsprintf( szError,
  54. "Case 1 - Trying to GET back the user calendar \"%s\", Current Active codepage: %d and the return Error Code: %d, count: %d",
  55. szSavedCalendarType,
  56. GetACP(),
  57. dwError,
  58. i);
  59. MessageBeep(0);
  60. MessageBox(NULL, szError, "Error in GetLocaleInfo", MB_OK | MB_ICONEXCLAMATION);
  61. }
  62. printf(".");
  63. i++;
  64. }
  65. }