bthapi.pp 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2008 Free Pascal development team.
  4. See the file COPYING.FPC, included in this distribution,
  5. for details about the copyright.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  9. ********************************************************************** }
  10. //
  11. // Module: bthapi.h, bthapi.idl
  12. //
  13. //
  14. // Microsoft Windows Mobile 6.0 for PocketPC SDK.
  15. //
  16. unit bthapi;
  17. {$MODE OBJFPC}
  18. interface
  19. uses Windows;
  20. const
  21. LIBID_BTHAPILib:TIID = '{00BC26C8-0A87-41d0-82BA-61FF9E0B1BB5}';
  22. const
  23. IID_ISdpWalk:TIID = '{57134AE6-5D3C-462D-BF2F-810361FBD7E7}';
  24. IID_ISdpNodeContainer:TIID = '{43F6ED49-6E22-4F81-A8EB-DCED40811A77}';
  25. IID_ISdpSearch:TIID = '{D93B6B2A-5EEF-4E1E-BECF-F5A4340C65F5}';
  26. IID_ISdpStream = '{A6ECD9FB-0C7A-41A3-9FF0-0B617E989357}';
  27. IID_ISdpRecord:TIID = '{10276714-1456-46D7-B526-8B1E83D5116E}';
  28. IID_IBluetoothDevice:TIID = '{5BD0418B-D705-4766-B215-183E4EADE341}';
  29. IID_IBluetoothAuthenticate:TIID = '{5F0FBA2B-8300-429D-99AD-96A2835D4901}';
  30. const
  31. CLSID_SdpNodeContainer:CLSID = '{D5CA76C5-0DEE-4453-96A1-E603C2401766}';
  32. CLSID_SdpSearch:CLSID = '{3B898402-857E-4E41-9145-BC35431B7B4D}';
  33. CLSID_SdpWalk:CLSID = '{ED384010-59AE-44c7-8FCA-F3DF22CDCD28}';
  34. CLSID_SdpStream:CLSID = '{249797FA-19DB-4dda-94D4-E0BCD30EA65E}';
  35. CLSID_SdpRecord:CLSID = '{ACD02BA7-9667-4085-A100-CC6ACA9621D6}';
  36. {$IFNDEF __BTHSDPDEF_H__}
  37. type
  38. SDP_LARGE_INTEGER_16 = record
  39. LowPart:ULONGLONG;
  40. HighPart:LONGLONG;
  41. end;
  42. PSDP_LARGE_INTEGER_16 = ^SDP_LARGE_INTEGER_16;
  43. LPSDP_LARGE_INTEGER_16 = ^SDP_LARGE_INTEGER_16;
  44. SDP_ULARGE_INTEGER_16 = record
  45. LowPart:ULONGLONG;
  46. HighPart:ULONGLONG;
  47. end;
  48. PSDP_ULARGE_INTEGER_16 = ^SDP_ULARGE_INTEGER_16;
  49. LPSDP_ULARGE_INTEGER_16 = ^SDP_ULARGE_INTEGER_16;
  50. type
  51. NodeContainerType = (NodeContainerTypeSequence := 0,
  52. NodeContainerTypeAlternative);
  53. PNodeContainerType = ^NodeContainerType;
  54. type
  55. SDP_ERROR = USHORT;
  56. PSDP_ERROR = ^SDP_ERROR;
  57. type
  58. SDP_TYPE = (SDP_TYPE_NIL := 0,
  59. SDP_TYPE_UINT := $1,
  60. SDP_TYPE_INT := $2,
  61. SDP_TYPE_UUID := $3,
  62. SDP_TYPE_STRING := $4,
  63. SDP_TYPE_BOOLEAN := $5,
  64. SDP_TYPE_SEQUENCE := $6,
  65. SDP_TYPE_ALTERNATIVE := $7,
  66. SDP_TYPE_URL := $8,
  67. SDP_TYPE_CONTAINER := $20);
  68. PSDP_TYPE = ^SDP_TYPE;
  69. SDP_SPECIFICTYPE = (SDP_ST_NONE := 0,
  70. SDP_ST_UINT8 := $10,
  71. SDP_ST_INT8 := $20,
  72. SDP_ST_UINT16 := $110,
  73. SDP_ST_INT16 := $120,
  74. SDP_ST_UUID16 := $130,
  75. SDP_ST_UINT32 := $210,
  76. SDP_ST_INT32 := $220,
  77. SDP_ST_UUID32 := $230,
  78. SDP_ST_UINT64 := $310,
  79. SDP_ST_INT64 := $320,
  80. SDP_ST_UINT128 := $410,
  81. SDP_ST_INT128 := $420,
  82. SDP_ST_UUID128 := $430);
  83. PSDP_SPECIFICTYPE = ^SDP_SPECIFICTYPE;
  84. type
  85. _SdpAttributeRange = record
  86. minAttribute:USHORT;
  87. maxAttribute:USHORT;
  88. end;
  89. SdpAttributeRange = _SdpAttributeRange;
  90. PSdpAttributeRange = ^_SdpAttributeRange;
  91. type
  92. SdpQueryUuidUnion = record
  93. case integer of
  94. 0: (uuid128:GUID);
  95. 1: (uuid32:ULONG);
  96. 2: (uuid16:USHORT);
  97. end;
  98. type
  99. _SdpQueryUuid = record
  100. u:SdpQueryUuidUnion;
  101. uuidType:USHORT;
  102. end;
  103. SdpQueryUuid = _SdpQueryUuid;
  104. PSdpQueryUuid = ^_SdpQueryUuid;
  105. const
  106. BTH_SDP_VERSION = 1;
  107. type
  108. _BTHNS_SETBLOB = record
  109. pSdpVersion:PULONG;
  110. pRecordHandle:PULONG;
  111. Reserved:array[0..3] of ULONG;
  112. fSecurity:ULONG;
  113. fOptions:ULONG;
  114. ulRecordLength:ULONG;
  115. pRecord:array[0..0] of UCHAR;
  116. end;
  117. BTHNS_SETBLOB = _BTHNS_SETBLOB;
  118. PBTHNS_SETBLOB = ^_BTHNS_SETBLOB;
  119. const
  120. MAX_UUIDS_IN_QUERY = 12;
  121. SDP_SERVICE_SEARCH_REQUEST = 1;
  122. SDP_SERVICE_ATTRIBUTE_REQUEST = 2;
  123. SDP_SERVICE_SEARCH_ATTRIBUTE_REQUEST = 3;
  124. //
  125. // The following may be passed as parameters to BthNsLookupServiceNext as extended
  126. // dwFlags options for device inquiry.
  127. //
  128. const
  129. // Causes traversal through list to be reset to first element.
  130. BTHNS_LUP_RESET_ITERATOR = $00010000;
  131. // Does not increment list, causes next query to be performed on current item as well.
  132. BTHNS_LUP_NO_ADVANCE = $00020000;
  133. // Causes LookupServiceEnd to abort current inquiry.
  134. BTHNS_ABORT_CURRENT_INQUIRY = $fffffffd;
  135. type
  136. _BTHNS_INQUIRYBLOB = record
  137. LAP:ULONG;
  138. _length:byte;
  139. num_responses:byte;
  140. end;
  141. BTHNS_INQUIRYBLOB = _BTHNS_INQUIRYBLOB;
  142. PBTHNS_INQUIRYBLOB = ^_BTHNS_INQUIRYBLOB;
  143. type
  144. _BTHNS_RESTRICTIONBLOB = record
  145. _type:ULONG;
  146. serviceHandle:ULONG;
  147. uuids:array[0..11] of SdpQueryUuid;
  148. numRange:ULONG;
  149. pRange:array[0..0] of SdpAttributeRange;
  150. end;
  151. BTHNS_RESTRICTIONBLOB = _BTHNS_RESTRICTIONBLOB;
  152. PBTHNS_RESTRICTIONBLOB = ^_BTHNS_RESTRICTIONBLOB;
  153. {$DEFINE __BTHSDPDEF_H__}
  154. {$ENDIF __BTHSDPDEF_H__}
  155. type
  156. SdpString = record
  157. val:^ShortInt;
  158. _length:ULONG;
  159. end;
  160. //
  161. // flags for fConnect in SdpSearch::Connect
  162. //
  163. const
  164. SDP_SEARCH_LOCAL = $00000001;
  165. SDP_SEARCH_CACHED = $00000002;
  166. type
  167. // Forward declarations.
  168. ISdpNodeContainer = interface;
  169. ISdpRecord = interface;
  170. PISdpRecord = ^ISdpRecord;
  171. PPISdpRecord = ^PISdpRecord;
  172. NodeDataUnion = record
  173. case integer of
  174. 0: (int128:SDP_LARGE_INTEGER_16);
  175. 1: (uint128:SDP_ULARGE_INTEGER_16);
  176. 2: (uuid128:GUID);
  177. 3: (uuid32:ULONG);
  178. 4: (uuid16:USHORT);
  179. 5: (int64:LONGLONG);
  180. 6: (uint64:ULONGLONG);
  181. 7: (int32:LONG);
  182. 8: (uint32:ULONG);
  183. 9: (int16:SHORT);
  184. 10: (uint16:USHORT);
  185. 11: (int8:ShortInt);
  186. 12: (uint8:UCHAR);
  187. 13: (booleanVal:UCHAR);
  188. 14: (str:SdpString);
  189. 15: (url:SdpString);
  190. 16: (container:pointer{ISdpNodeContainer});
  191. end;
  192. NodeData = record
  193. _type:USHORT;
  194. specificType:USHORT;
  195. u:NodeDataUnion;
  196. end;
  197. PNODEDATA = ^NodeData;
  198. BthDeviceStringType = (BthDeviceStringTypeFriendlyName := 0,
  199. BthDeviceStringTypeDeviceName,
  200. BthDeviceStringTypeDisplay,
  201. BthDeviceStringTypeClass,
  202. BthDeviceStringTypeAddress);
  203. // #pragma pack(push)
  204. // #pragma pack(1)
  205. {$PACKRECORDS 1}
  206. _BthDeviceInfo = record
  207. btAddress:ULONGLONG;
  208. cod:ULONG;
  209. lmpSupportedFeatures:ULONGLONG;
  210. name:array[0..247] of ShortInt;
  211. end;
  212. BthDeviceInfo = _BthDeviceInfo;
  213. PBthDeviceInfo = ^_BthDeviceInfo;
  214. {$PACKRECORDS DEFAULT}
  215. // #pragma pack(pop)
  216. // Needful types.
  217. PPUCHAR = ^PUCHAR;
  218. PPUSHORT = ^PUSHORT;
  219. PPWCHAR = ^PWCHAR;
  220. ISdpWalk = interface(IUnknown)
  221. ['{57134AE6-5D3C-462D-BF2F-810361FBD7E7}']
  222. function WalkNode(pData:PNODEDATA; state:ULONG):HRESULT; stdcall;
  223. function WalkStream(elementType:UCHAR; elementSize:ULONG; pStream:PUCHAR):HRESULT; stdcall;
  224. end;
  225. ISdpNodeContainer = interface(IUnknown)
  226. ['{43F6ED49-6E22-4F81-A8EB-DCED40811A77}']
  227. function CreateStream(out ppStream:PUCHAR;{ppStream:PPUCHAR;} pSize:PULONG):HRESULT; stdcall;
  228. function WriteStream(pStream:PUCHAR; pNumBytesWritten:PULONG):HRESULT; stdcall;
  229. function AppendNode(pData:PNODEDATA):HRESULT; stdcall;
  230. function GetType(pType:PNodeContainerType):HRESULT; stdcall;
  231. function SetType(_type:NodeContainerType):HRESULT; stdcall;
  232. function Walk(pWalk:ISdpWalk):HRESULT; stdcall;
  233. function SetNode(nodeIndex:ULONG; pData:PNODEDATA):HRESULT; stdcall;
  234. function GetNode(nodeIndex:ULONG; pData:PNODEDATA):HRESULT; stdcall;
  235. function LockContainer(lock:UCHAR):HRESULT; stdcall;
  236. function GetNodeCount(pNodeCount:PULONG):HRESULT; stdcall;
  237. function CreateFromStream(pStream:PUCHAR; _size:ULONG):HRESULT; stdcall;
  238. function GetNodeStringData(nodeIndex:ULONG; pData:PNODEDATA):HRESULT; stdcall;
  239. function GetStreamSize(pSize:PULONG):HRESULT; stdcall;
  240. end;
  241. ISdpSearch = interface(IUnknown)
  242. ['{D93B6B2A-5EEF-4E1E-BECF-F5A4340C65F5}']
  243. function _Begin(pAddrss:PULONGLONG; fConnect:ULONG):HRESULT; stdcall;
  244. function _End:HRESULT; stdcall;
  245. function ServiceSearch(pUuidList:PSdpQueryUuid;
  246. listSize:ULONG;
  247. pHandles:PULONG;
  248. pNumHandles:PUSHORT):HRESULT; stdcall;
  249. function AttributeSearch(_handle:ULONG;
  250. pRangeListP:SdpAttributeRange;
  251. numRanges:ULONG;
  252. out ppSdpRecord:ISdpRecord{ppSdpRecord:PISdpRecord}):HRESULT; stdcall;
  253. function ServiceAndAttributeSearch(pUuidList:PSdpQueryUuid;
  254. listSize:ULONG;
  255. pRangeList:PSdpAttributeRange;
  256. numRanges:ULONG;
  257. out pppSdpRecord:PISdpRecord{pppSdpRecord:PPISdpRecord};
  258. pNumRecords:PULONG):HRESULT; stdcall;
  259. end;
  260. ISdpStream = interface(IUnknown)
  261. ['{A6ECD9FB-0C7A-41A3-9FF0-0B617E989357}']
  262. {$IF DEFINED(WINCE) OR DEFINED(WINCE_EMULATION)}
  263. function Validate(pStream:PUCHAR; _size:ULONG; pErrorByte:PULONG):HRESULT; stdcall;
  264. {$ELSE}
  265. function Validate(pStream:PUCHAR; _size:ULONG; pErrorByte:PULONG_PTR):HRESULT; stdcall;
  266. {$ENDIF}
  267. function Walk(pStream:PUCHAR; _size:ULONG; pWalk:ISdpWalk):HRESULT; stdcall;
  268. function RetrieveRecords(pStream:PUCHAR; _size:ULONG; var ppSdpRecords:ISdpRecord;{ppSdpRecords:PISdpRecord;} pNumRecords:PULONG):HRESULT; stdcall;
  269. function RetrieveUuid128(pStream:PUCHAR; pUuid128:PGUID):HRESULT; stdcall;
  270. function RetrieveUint16(pStream:PUCHAR; pUint16:PUSHORT):HRESULT; stdcall;
  271. function RetrieveUint32(pStream:PUCHAR; pUint32:ULONG):HRESULT; stdcall;
  272. function RetrieveUint64(pStream:PUCHAR; pUint64:PULONGLONG):HRESULT; stdcall;
  273. function RetrieveUint128(pStream:PUCHAR; pUint128:PSDP_ULARGE_INTEGER_16):HRESULT; stdcall;
  274. function RetrieveInt16(pStream:PUCHAR; pInt16:PSHORT):HRESULT; stdcall;
  275. function RetrieveInt32(pStream:PUCHAR; pInt32:PLONG):HRESULT; stdcall;
  276. function RetrieveInt64(pStream:PUCHAR; pInt64:PLONGLONG):HRESULT; stdcall;
  277. function RetrieveInt128(pStream:PUCHAR; pInt128:PSDP_LARGE_INTEGER_16):HRESULT; stdcall;
  278. function ByteSwapUuid128(pInUuid128:PGUID; pOutUuid128:PGUID):HRESULT; stdcall;
  279. function ByteSwapUint128(pInUint128:PSDP_ULARGE_INTEGER_16; pOutUint128:PSDP_ULARGE_INTEGER_16):HRESULT; stdcall;
  280. function ByteSwapUint64(inUint64:ULONGLONG; pOutUint64:PULONGLONG):HRESULT; stdcall;
  281. function ByteSwapUint32(uint32:ULONG; pUint32:PULONG):HRESULT; stdcall;
  282. function ByteSwapUint16(uint16:USHORT; pUint16:PUSHORT):HRESULT; stdcall;
  283. function ByteSwapInt128(pInInt128:PSDP_LARGE_INTEGER_16; pOutInt128:PSDP_LARGE_INTEGER_16):HRESULT; stdcall;
  284. function ByteSwapInt64(inInt64:LONGLONG; pOutInt64:PLONGLONG):HRESULT; stdcall;
  285. function ByteSwapInt32(int32:LONG; pInt32:PLONG):HRESULT; stdcall;
  286. function ByteSwapInt16(int16:SHORT; pInt16:PSHORT):HRESULT; stdcall;
  287. function NormalizeUuid(pDataUuid:PNODEDATA; pNormalizeUuid:PGUID):HRESULT; stdcall;
  288. function RetrieveElementInfo(pStream:PUCHAR;
  289. pElementType:PSDP_TYPE;
  290. pElementSpecificType:PSDP_SPECIFICTYPE;
  291. pElementSize:PULONG;
  292. pStorageSize:PULONG;
  293. out ppData:PUCHAR{ppData:PPUCHAR}):HRESULT; stdcall;
  294. function VerifySequenceOf(pStream:PUCHAR; _size:PULONG; ofType:SDP_TYPE; pSpecificSizes:PUCHAR; pNumFound:PULONG):HRESULT; stdcall;
  295. end;
  296. ISdpRecord = interface(IUnknown)
  297. ['{10276714-1456-46D7-B526-8B1E83D5116E}']
  298. function CreateFromStream(pStream:PUCHAR; _size:ULONG):HRESULT; stdcall;
  299. function WriteToStream(out ppStream:PUCHAR;{ppStream:PPUCHAR;} pStreamSize:PULONG; preSize:ULONG; postSize:ULONG):HRESULT; stdcall;
  300. function SetAttribute(attribute:USHORT; pNode:PNODEDATA):HRESULT; stdcall;
  301. function SetAttributeFromStream(attribute:USHORT; pStream:PUCHAR; _size:ULONG):HRESULT; stdcall;
  302. function GetAttribute(attribute:USHORT; pNode:PNODEDATA):HRESULT; stdcall;
  303. function GetAttributeAsStream(attribute:USHORT; out ppStream:PUCHAR;{ppStream:PPUCHAR;} pSize:PULONG):HRESULT; stdcall;
  304. function Walk(pWalk:ISdpWalk):HRESULT; stdcall;
  305. function GetAttributeList(out ppList:PUSHORT;{ppList:PPUSHORT;} pListSize:PULONG):HRESULT; stdcall;
  306. function GetString(_offset:USHORT; pLangId:PUSHORT; var ppString:PWCHAR{ppString:PPWCHAR}):HRESULT; stdcall;
  307. function GetIcon(cxRes:longint; cyRes:longint; phIcon:LPHICON):HRESULT; stdcall;
  308. function GetServiceClass(pServiceClass:LPGUID):HRESULT; stdcall;
  309. end;
  310. IBluetoothDevice = interface(IUnknown)
  311. ['{5BD0418B-D705-4766-B215-183E4EADE341}']
  312. function Initialize(pInfo:PBthDeviceInfo):HRESULT; stdcall;
  313. function GetInfo(pInfo:PBthDeviceInfo):HRESULT; stdcall;
  314. function GetString(_type:BthDeviceStringType; var ppString:PWCHAR{ppString:PPWCHAR}):HRESULT; stdcall;
  315. function SetString(_type:BthDeviceStringType; pString:PWCHAR):HRESULT; stdcall;
  316. function GetIcon(cxRes:longint; cyRes:longint; phIcon:LPHICON):HRESULT; stdcall;
  317. function GetApprovedServices(pServices:PGUID; pServiceCount:PULONG):HRESULT; stdcall;
  318. function GetPassKey(hwndParent:HWND; pPassKey:PUCHAR; pPassKeyLength:PUCHAR):HRESULT; stdcall;
  319. end;
  320. IBluetoothAuthenticate = interface(IUnknown)
  321. ['{5F0FBA2B-8300-429D-99AD-96A2835D4901}']
  322. end;
  323. implementation
  324. end.