Source code of Windows XP (NT5)
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.

225 lines
3.8 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1997 - 1999
  6. //
  7. // File: event.cpp
  8. //
  9. //--------------------------------------------------------------------------
  10. #include "windows.h"
  11. #include <stdio.h>
  12. #include <string.h>
  13. #include <assert.h>
  14. #include "crtem.h"
  15. #include "unicode.h"
  16. #ifdef _M_IX86
  17. HANDLE
  18. WINAPI
  19. CreateEvent9x(
  20. LPSECURITY_ATTRIBUTES lpEventAttributes,
  21. BOOL bManualReset,
  22. BOOL bInitialState,
  23. LPCWSTR lpName)
  24. {
  25. BYTE rgb[_MAX_PATH];
  26. char *sz = NULL;
  27. HANDLE hEvent = NULL;
  28. if (MkMBStr(rgb, _MAX_PATH, lpName, &sz))
  29. {
  30. hEvent = CreateEventA( lpEventAttributes,
  31. bManualReset,
  32. bInitialState,
  33. sz);
  34. FreeMBStr(rgb, sz);
  35. }
  36. return hEvent;
  37. }
  38. HANDLE
  39. WINAPI
  40. CreateEventU(
  41. LPSECURITY_ATTRIBUTES lpEventAttributes,
  42. BOOL bManualReset,
  43. BOOL bInitialState,
  44. LPCWSTR lpName)
  45. {
  46. if (FIsWinNT())
  47. return CreateEventW(lpEventAttributes,
  48. bManualReset,
  49. bInitialState,
  50. lpName);
  51. else
  52. return CreateEvent9x(lpEventAttributes,
  53. bManualReset,
  54. bInitialState,
  55. lpName);
  56. }
  57. HANDLE
  58. WINAPI
  59. RegisterEventSource9x(
  60. LPCWSTR lpUNCServerName,
  61. LPCWSTR lpSourceName)
  62. {
  63. BYTE rgb[_MAX_PATH];
  64. BYTE rgb2[_MAX_PATH];
  65. char *sz = NULL;
  66. char *sz2 = NULL;
  67. HANDLE hEvent = NULL;
  68. if ((MkMBStr(rgb, _MAX_PATH, lpUNCServerName, &sz)) &&
  69. (MkMBStr(rgb2, _MAX_PATH, lpSourceName, &sz2)))
  70. {
  71. hEvent = RegisterEventSourceA( sz,
  72. sz2);
  73. FreeMBStr(rgb, sz);
  74. FreeMBStr(rgb2, sz2);
  75. }
  76. return hEvent;
  77. }
  78. HANDLE
  79. WINAPI
  80. RegisterEventSourceU(
  81. LPCWSTR lpUNCServerName,
  82. LPCWSTR lpSourceName)
  83. {
  84. if (FIsWinNT())
  85. return RegisterEventSourceW(lpUNCServerName,
  86. lpSourceName);
  87. else
  88. return RegisterEventSource9x(lpUNCServerName,
  89. lpSourceName);
  90. }
  91. HANDLE
  92. WINAPI
  93. OpenEvent9x(
  94. DWORD dwDesiredAccess,
  95. BOOL bInheritHandle,
  96. LPCWSTR lpName)
  97. {
  98. BYTE rgb[_MAX_PATH];
  99. char *sz = NULL;
  100. HANDLE hEvent = NULL;
  101. if (MkMBStr(rgb, _MAX_PATH, lpName, &sz))
  102. {
  103. hEvent = OpenEventA(dwDesiredAccess,
  104. bInheritHandle,
  105. sz);
  106. FreeMBStr(rgb, sz);
  107. }
  108. return hEvent;
  109. }
  110. HANDLE
  111. WINAPI
  112. OpenEventU(
  113. DWORD dwDesiredAccess,
  114. BOOL bInheritHandle,
  115. LPCWSTR lpName)
  116. {
  117. if (FIsWinNT())
  118. return OpenEventW( dwDesiredAccess,
  119. bInheritHandle,
  120. lpName);
  121. else
  122. return OpenEvent9x( dwDesiredAccess,
  123. bInheritHandle,
  124. lpName);
  125. }
  126. HANDLE
  127. WINAPI
  128. CreateMutex9x(
  129. LPSECURITY_ATTRIBUTES lpMutexAttributes,
  130. BOOL bInitialOwner,
  131. LPCWSTR lpName)
  132. {
  133. BYTE rgb[_MAX_PATH];
  134. char *sz = NULL;
  135. HANDLE hMutex = NULL;
  136. if (MkMBStr(rgb, _MAX_PATH, lpName, &sz))
  137. {
  138. hMutex = CreateMutexA( lpMutexAttributes,
  139. bInitialOwner,
  140. sz);
  141. FreeMBStr(rgb, sz);
  142. }
  143. return hMutex;
  144. }
  145. HANDLE
  146. WINAPI
  147. CreateMutexU(
  148. LPSECURITY_ATTRIBUTES lpMutexAttributes,
  149. BOOL bInitialOwner,
  150. LPCWSTR lpName)
  151. {
  152. if (FIsWinNT())
  153. return CreateMutexW(lpMutexAttributes,
  154. bInitialOwner,
  155. lpName);
  156. else
  157. return CreateMutex9x(lpMutexAttributes,
  158. bInitialOwner,
  159. lpName);
  160. }
  161. HANDLE
  162. WINAPI
  163. OpenMutex9x(
  164. DWORD dwDesiredAccess,
  165. BOOL bInheritHandle,
  166. LPCWSTR lpName)
  167. {
  168. BYTE rgb[_MAX_PATH];
  169. char *sz = NULL;
  170. HANDLE hMutex = NULL;
  171. if (MkMBStr(rgb, _MAX_PATH, lpName, &sz))
  172. {
  173. hMutex = OpenMutexA(dwDesiredAccess,
  174. bInheritHandle,
  175. sz);
  176. FreeMBStr(rgb, sz);
  177. }
  178. return hMutex;
  179. }
  180. HANDLE
  181. WINAPI
  182. OpenMutexU(
  183. DWORD dwDesiredAccess,
  184. BOOL bInheritHandle,
  185. LPCWSTR lpName)
  186. {
  187. if (FIsWinNT())
  188. return OpenMutexW( dwDesiredAccess,
  189. bInheritHandle,
  190. lpName);
  191. else
  192. return OpenMutex9x( dwDesiredAccess,
  193. bInheritHandle,
  194. lpName);
  195. }
  196. #endif // _M_IX86