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.

96 lines
3.5 KiB

  1. /*---------------------------------------------------------------------------
  2. | WINVER.C - Windows Version program
  3. |
  4. | History:
  5. | 03/08/89 Toddla Created
  6. |
  7. *--------------------------------------------------------------------------*/
  8. #include <nt.h>
  9. #include <ntrtl.h>
  10. #include <nturtl.h>
  11. #include <windows.h>
  12. #include <port1632.h>
  13. #include <stdio.h>
  14. #include "winverp.h"
  15. #include <shellapi.h>
  16. #include <strsafe.h>
  17. #ifndef ARRAYSIZE
  18. #define ARRAYSIZE(x) (sizeof(x) / sizeof(x[0]))
  19. #endif
  20. BOOL FileTimeToDateTimeString(
  21. LPFILETIME pft,
  22. LPTSTR pszBuf,
  23. UINT cchBuf)
  24. {
  25. SYSTEMTIME st;
  26. int cch;
  27. FileTimeToLocalFileTime(pft, pft);
  28. if (FileTimeToSystemTime(pft, &st))
  29. {
  30. cch = GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &st, NULL, pszBuf, cchBuf);
  31. if (cch > 0)
  32. {
  33. cchBuf -= cch;
  34. pszBuf += cch - 1;
  35. *pszBuf++ = TEXT(' ');
  36. *pszBuf = 0; // (in case GetTimeFormat doesn't add anything)
  37. cchBuf--;
  38. GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &st, NULL, pszBuf, cchBuf);
  39. return TRUE;
  40. }
  41. }
  42. return FALSE;
  43. }
  44. /*----------------------------------------------------------------------------*\
  45. | WinMain( hInst, hPrev, lpszCmdLine, cmdShow ) |
  46. | |
  47. | Description: |
  48. | The main procedure for the App. After initializing, it just goes |
  49. | into a message-processing loop until it gets a WM_QUIT message |
  50. | (meaning the app was closed). |
  51. | |
  52. | Arguments: |
  53. | hInst instance handle of this instance of the app |
  54. | hPrev instance handle of previous instance, NULL if first |
  55. | lpszCmdLine ->null-terminated command line |
  56. | cmdShow specifies how the window is initially displayed |
  57. | |
  58. | Returns: |
  59. | The exit code as specified in the WM_QUIT message. |
  60. | |
  61. \*----------------------------------------------------------------------------*/
  62. INT
  63. __cdecl
  64. ModuleEntry()
  65. {
  66. TCHAR szTitle[32];
  67. LARGE_INTEGER Time = USER_SHARED_DATA->SystemExpirationDate;
  68. if (LoadString(GetModuleHandle(NULL), IDS_APPTITLE, szTitle, ARRAYSIZE(szTitle)))
  69. {
  70. if (Time.QuadPart)
  71. {
  72. TCHAR szExtra[128];
  73. TCHAR szTime[128];
  74. if (FileTimeToDateTimeString((PFILETIME)&Time, szTime, ARRAYSIZE(szTime))
  75. && LoadString(GetModuleHandle(NULL), IDS_EVALUATION, szExtra, ARRAYSIZE(szExtra)))
  76. {
  77. StringCchCat(szExtra, ARRAYSIZE(szExtra), szTime);
  78. ShellAbout(NULL, szTitle, szExtra, NULL);
  79. }
  80. } else
  81. {
  82. ShellAbout(NULL, szTitle, NULL, NULL);
  83. }
  84. }
  85. return 0;
  86. }