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.

145 lines
3.3 KiB

  1. #include "hwxobj.h"
  2. #include "memmgr.h"
  3. #ifdef UNDER_CE // Windows CE Stub for unsupported APIs
  4. #include "stub_ce.h"
  5. #endif // UNDER_CE
  6. // implementation of CHwxObject
  7. HINSTANCE CHwxObject::m_hInstance = NULL;
  8. void * CHwxObject::operator new(size_t size)
  9. {
  10. return MemAlloc(size);
  11. }
  12. void CHwxObject::operator delete(void * pv)
  13. {
  14. if(pv)
  15. {
  16. MemFree(pv);
  17. }
  18. }
  19. CHwxObject::CHwxObject(HINSTANCE hInstance)
  20. {
  21. m_nLen = 0;
  22. m_pClassName[m_nLen] = (TCHAR)'\0';
  23. if ( !m_hInstance )
  24. m_hInstance = hInstance;
  25. }
  26. CHwxObject::~CHwxObject()
  27. {
  28. if ( m_nLen && m_pClassName )
  29. {
  30. m_nLen = 0;
  31. m_pClassName[m_nLen] = (TCHAR)'\0';
  32. }
  33. }
  34. BOOL CHwxObject::Initialize(TCHAR * pClsName)
  35. {
  36. BOOL bRet = TRUE;
  37. if ( pClsName )
  38. {
  39. #ifndef UNDER_CE
  40. //990617:ToshiaK. This below code is wired...
  41. lstrcpyn(m_pClassName, pClsName, 16);
  42. m_nLen = lstrlen(m_pClassName);
  43. #if 0
  44. m_nLen = strlen(pClsName); // must be less than 16
  45. m_nLen = m_nLen > 16 ? 16 : m_nLen;
  46. pClsName[m_nLen] = (TCHAR)'\0';
  47. strcpy(m_pClassName,pClsName);
  48. #endif
  49. #else // UNDER_CE
  50. int cnsize = sizeof m_pClassName/sizeof m_pClassName[0];
  51. _tcsncpy(m_pClassName, pClsName, cnsize);
  52. m_pClassName[cnsize-1] = TEXT('\0');
  53. m_nLen = lstrlen(m_pClassName);
  54. #endif // UNDER_CE
  55. // m_pClassName =(TCHAR *) new TCHAR[m_nLen + 1];
  56. // if ( m_pClassName )
  57. // {
  58. // strcpy(m_pClassName,pClsName);
  59. // }
  60. // else
  61. // bRet = FALSE;
  62. }
  63. else
  64. {
  65. m_nLen = 0;
  66. m_pClassName[m_nLen] = (TCHAR)'\0';
  67. }
  68. return bRet;
  69. }
  70. static POSVERSIONINFO GetOSVersion(VOID)
  71. {
  72. static BOOL fFirst = TRUE;
  73. static OSVERSIONINFO os;
  74. if ( fFirst ) {
  75. os.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
  76. if (GetVersionEx( &os ) ) {
  77. fFirst = FALSE;
  78. }
  79. }
  80. return &os;
  81. }
  82. BOOL IsWin95(VOID)
  83. {
  84. BOOL fBool;
  85. fBool = (GetOSVersion()->dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) &&
  86. (GetOSVersion()->dwMajorVersion >= 4) &&
  87. (GetOSVersion()->dwMinorVersion < 10);
  88. return fBool;
  89. }
  90. BOOL IsWin98(VOID)
  91. {
  92. BOOL fBool;
  93. fBool = (GetOSVersion()->dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) &&
  94. (GetOSVersion()->dwMajorVersion >= 4) &&
  95. (GetOSVersion()->dwMinorVersion >= 10);
  96. return fBool;
  97. }
  98. BOOL IsWinNT4(VOID)
  99. {
  100. BOOL fBool;
  101. fBool = (GetOSVersion()->dwPlatformId == VER_PLATFORM_WIN32_NT) &&
  102. (GetOSVersion()->dwMajorVersion == 4);
  103. return fBool;
  104. }
  105. BOOL IsWinNT5(VOID)
  106. {
  107. BOOL fBool;
  108. fBool = (GetOSVersion()->dwPlatformId == VER_PLATFORM_WIN32_NT) &&
  109. (GetOSVersion()->dwMajorVersion == 5);
  110. return fBool;
  111. }
  112. BOOL IsWinNT5orUpper()
  113. {
  114. static BOOL fFirstCallNT5 = TRUE;
  115. static BOOL fNT5 = FALSE;
  116. if (fFirstCallNT5 == FALSE)
  117. return fNT5;
  118. fFirstCallNT5 = FALSE;
  119. fNT5 = (GetOSVersion()->dwPlatformId == VER_PLATFORM_WIN32_NT) &&
  120. (GetOSVersion()->dwMajorVersion >= 5);
  121. return fNT5;
  122. }
  123. BOOL IsWinNT(VOID)
  124. {
  125. return (BOOL)(GetOSVersion()->dwPlatformId == VER_PLATFORM_WIN32_NT);
  126. }