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.

321 lines
6.5 KiB

  1. //+-------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1993-1999.
  5. //
  6. // File: msports.h
  7. //
  8. // Contents: public header file for COM name arbitration database
  9. // and Advanced dialog override and invocation
  10. //
  11. //--------------------------------------------------------------------
  12. #ifndef _MSPORTS_H
  13. #define _MSPORTS_H
  14. #if _MSC_VER > 1000
  15. #pragma once
  16. #endif
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. #ifdef SERIAL_ADVANCED_SETTINGS
  21. /*++
  22. Routine Description:
  23. Displays the advanced properties dialog for the COM port specified by
  24. DeviceInfoSet and DeviceInfoData.
  25. Arguments:
  26. ParentHwnd - the parent window of the window to be displayed
  27. DeviceInfoSet, DeviceInfoData - SetupDi structures representing the COM port
  28. Return Value:
  29. ERROR_SUCCESS if the dialog was shown
  30. --*/
  31. LONG
  32. SerialDisplayAdvancedSettings(IN HWND ParentHwnd,
  33. IN HDEVINFO DeviceInfoSet,
  34. IN PSP_DEVINFO_DATA DeviceInfoData
  35. );
  36. /*++
  37. Routine Description:
  38. Prototype to allow serial port vendors to override the advanced dialog
  39. represented by the COM port specified by DeviceInfoSet and DeviceInfoData.
  40. To override the advanced page, place a value named EnumAdvancedDialog under
  41. the same key in which you would put your EnumPropPages32 value. The format
  42. of the value is exactly the same as Enum...32 as well.
  43. Arguments:
  44. ParentHwnd - the parent window of the window to be displayed
  45. HidePollingUI - If TRUE, hide all UI that deals with polling.
  46. DeviceInfoSet, DeviceInfoData - SetupDi structures representing the COM port
  47. Reserved - Unused
  48. Return Value:
  49. TRUE if the user pressed OK, FALSE if Cancel was pressed
  50. --*/
  51. typedef
  52. BOOL
  53. (*PPORT_ADVANCED_DIALOG) (
  54. IN HWND ParentHwnd,
  55. IN BOOL HidePollingUI,
  56. IN HDEVINFO DeviceInfoSet,
  57. IN PSP_DEVINFO_DATA DeviceInfoData,
  58. IN PVOID Reserved
  59. );
  60. #endif
  61. DECLARE_HANDLE(HCOMDB);
  62. typedef HCOMDB *PHCOMDB;
  63. #define HCOMDB_INVALID_HANDLE_VALUE ((HCOMDB) INVALID_HANDLE_VALUE)
  64. //
  65. // Minimum through maximum number of COM names arbitered
  66. //
  67. #define COMDB_MIN_PORTS_ARBITRATED 256
  68. #define COMDB_MAX_PORTS_ARBITRATED 4096
  69. LONG
  70. WINAPI
  71. ComDBOpen (
  72. PHCOMDB PHComDB
  73. );
  74. /*++
  75. Routine Description:
  76. Opens name data base, and returns a handle to be used in future calls.
  77. Arguments:
  78. None.
  79. Return Value:
  80. INVALID_HANDLE_VALUE if the call fails, otherwise a valid handle
  81. If INVALID_HANDLE_VALUE, call GetLastError() to get details (??)
  82. --*/
  83. LONG
  84. WINAPI
  85. ComDBClose (
  86. HCOMDB HComDB
  87. );
  88. /*++
  89. Routine Description:
  90. frees a handle to the database returned from OpenComPortDataBase
  91. Arguments:
  92. Handle returned from OpenComPortDataBase.
  93. Return Value:
  94. None
  95. --*/
  96. #define CDB_REPORT_BITS 0x0
  97. #define CDB_REPORT_BYTES 0x1
  98. LONG
  99. WINAPI
  100. ComDBGetCurrentPortUsage (
  101. HCOMDB HComDB,
  102. PBYTE Buffer,
  103. DWORD BufferSize,
  104. ULONG ReportType, // CDB_REPORT value
  105. LPDWORD MaxPortsReported
  106. );
  107. /*++
  108. Routine Description:
  109. if Buffer is NULL, than MaxPortsReported will contain the max number of ports
  110. the DB will report (this value is NOT the number of bytes need for Buffer).
  111. ReportType is ignored in this case.
  112. if ReportType == CDB_REPORT_BITS
  113. returns a bit array indicating if a comX name is claimed.
  114. ie, Bit 0 of Byte 0 is com1, bit 1 of byte 0 is com2 and so on.
  115. BufferSize >= MaxPortsReported / 8
  116. if ReportType == CDB_REPORT_BYTES
  117. returns a byte array indicating if a comX name is claimed. Zero unused, non zero
  118. used, ie, byte 0 is com1, byte 1 is com2, etc
  119. BufferSize >= MaxPortsReported
  120. Arguments:
  121. Handle returned from OpenComPortDataBase.
  122. Buffer pointes to memory to place bit array
  123. BufferSize Size of buffer in bytes
  124. MaxPortsReported Pointer to DWORD that holds the number of bytes in buffer filled in
  125. Return Value:
  126. returns ERROR_SUCCESS if successful.
  127. ERROR_NOT_CONNECTED cannot connect to DB
  128. ERROR_MORE_DATA if buffer not large enough
  129. --*/
  130. LONG
  131. WINAPI
  132. ComDBClaimNextFreePort (
  133. HCOMDB HComDB,
  134. LPDWORD ComNumber
  135. );
  136. /*++
  137. Routine Description:
  138. returns the first free COMx value
  139. Arguments:
  140. Handle returned from OpenComPortDataBase.
  141. Return Value:
  142. returns ERROR_SUCCESS if successful. or other ERROR_ if not
  143. if successful, then ComNumber will be that next free com value and claims it in the database
  144. --*/
  145. LONG
  146. WINAPI
  147. ComDBClaimPort (
  148. HCOMDB HComDB,
  149. DWORD ComNumber,
  150. BOOL ForceClaim,
  151. PBOOL Forced /* optional */
  152. );
  153. /*++
  154. Routine Description:
  155. Attempts to claim a com name in the database
  156. Arguments:
  157. DataBaseHandle - returned from OpenComPortDataBase.
  158. ComNumber - The port value to be claimed
  159. Force - If TRUE, will force the port to be claimed even if in use already
  160. Forced - will reflect the event that the claim was forced
  161. Return Value:
  162. returns ERROR_SUCCESS if port name was not already claimed, or if it was claimed
  163. and Force was TRUE.
  164. ERROR_SHARING_VIOLATION if port name is use and Force is false
  165. --*/
  166. LONG
  167. WINAPI
  168. ComDBReleasePort (
  169. HCOMDB HComDB,
  170. DWORD ComNumber
  171. );
  172. /*++
  173. Routine Description:
  174. Releases the port in the database
  175. Arguments:
  176. DatabaseHandle - returned from OpenComPortDataBase.
  177. ComNumber - port to be unclaimed in database
  178. Return Value:
  179. returns ERROR_SUCCESS if successful
  180. ERROR_CANTWRITE if the changes cannot be committed
  181. ERROR_INVALID_PARAMETER if ComNumber is greater than the number of
  182. ports arbitrated
  183. --*/
  184. LONG
  185. WINAPI
  186. ComDBResizeDatabase (
  187. HCOMDB HComDB,
  188. DWORD NewSize
  189. );
  190. /*++
  191. Routine Description:
  192. Resizes the database to the new size. To get the current size, call
  193. ComDBGetCurrentPortUsage with a Buffer == NULL.
  194. Arguments:
  195. DatabaseHandle - returned from OpenComPortDataBase.
  196. NewSize - must be a multiple of 1024, with a max of 4096
  197. Return Value:
  198. returns ERROR_SUCCESS if successful
  199. ERROR_CANTWRITE if the changes cannot be committed
  200. ERROR_BAD_LENGTH if NewSize is not greater than the current size or
  201. NewSize is greater than COMDB_MAX_PORTS_ARBITRATED
  202. --*/
  203. #ifdef __cplusplus
  204. }
  205. #endif
  206. #endif // _MSPORTS_H