jwabluetoothapis.pas 65 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013
  1. {******************************************************************************}
  2. { }
  3. { BlueTooth API interface Unit for Object Pascal }
  4. { }
  5. { Portions created by Microsoft are Copyright (C) 1995-2001 Microsoft }
  6. { Corporation. All Rights Reserved. }
  7. { }
  8. { Portions created by Marcel van Brakel are Copyright (C) 1999-2001 }
  9. { Marcel van Brakel. All Rights Reserved. }
  10. { }
  11. { Contributors: John Penman }
  12. { }
  13. { Obtained through: Joint Endeavour of Delphi Innovators (Project JEDI) }
  14. { }
  15. { You may retrieve the latest version of this file at the Project JEDI }
  16. { APILIB home page, located at http://jedi-apilib.sourceforge.net }
  17. { }
  18. { The contents of this file are used with permission, subject to the Mozilla }
  19. { Public License Version 1.1 (the "License"); you may not use this file except }
  20. { in compliance with the License. You may obtain a copy of the License at }
  21. { http://www.mozilla.org/MPL/MPL-1.1.html }
  22. { }
  23. { Software distributed under the License is distributed on an "AS IS" basis, }
  24. { WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for }
  25. { the specific language governing rights and limitations under the License. }
  26. { }
  27. { Alternatively, the contents of this file may be used under the terms of the }
  28. { GNU Lesser General Public License (the "LGPL License"), in which case the }
  29. { provisions of the LGPL License are applicable instead of those above. }
  30. { If you wish to allow use of your version of this file only under the terms }
  31. { of the LGPL License and not to allow others to use your version of this file }
  32. { under the MPL, indicate your decision by deleting the provisions above and }
  33. { replace them with the notice and other provisions required by the LGPL }
  34. { License. If you do not delete the provisions above, a recipient may use }
  35. { your version of this file under either the MPL or the LGPL License. }
  36. { }
  37. { For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html }
  38. { }
  39. {******************************************************************************}
  40. unit JwaBluetoothAPIs;
  41. {$WEAKPACKAGEUNIT}
  42. {$HPPEMIT ''}
  43. {$HPPEMIT '#include "bluetoothapis.h"'}
  44. {$HPPEMIT ''}
  45. {$I jediapilib.inc}
  46. interface
  47. uses
  48. JwaWinType, JwaWinBase, JwaBthSdpDef;
  49. const
  50. BLUETOOTH_MAX_NAME_SIZE = 248;
  51. {$EXTERNALSYM BLUETOOTH_MAX_NAME_SIZE}
  52. BLUETOOTH_MAX_PASSKEY_SIZE = 16;
  53. {$EXTERNALSYM BLUETOOTH_MAX_PASSKEY_SIZE}
  54. BLUETOOTH_MAX_PASSKEY_BUFFER_SIZE = BLUETOOTH_MAX_PASSKEY_SIZE + 1;
  55. {$EXTERNALSYM BLUETOOTH_MAX_PASSKEY_BUFFER_SIZE}
  56. // ***************************************************************************
  57. //
  58. // Bluetooth Address
  59. //
  60. // ***************************************************************************
  61. type
  62. BTH_ADDR = Int64;
  63. {$EXTERNALSYM BTH_ADDR}
  64. _BLUETOOTH_ADDRESS = record
  65. case Integer of
  66. 0: (ullLong: BTH_ADDR); // easier to compare again BLUETOOTH_NULL_ADDRESS
  67. 1: (rgBytes: array [0..5] of Byte); // easier to format when broken out
  68. end;
  69. {$EXTERNALSYM _BLUETOOTH_ADDRESS}
  70. BLUETOOTH_ADDRESS = _BLUETOOTH_ADDRESS;
  71. {$EXTERNALSYM BLUETOOTH_ADDRESS}
  72. TBlueToothAddress = BLUETOOTH_ADDRESS;
  73. PBlueToothAddress = ^BLUETOOTH_ADDRESS;
  74. const
  75. BLUETOOTH_NULL_ADDRESS: TBlueToothAddress = (ullLong: 0;);
  76. {$EXTERNALSYM BLUETOOTH_NULL_ADDRESS}
  77. // ***************************************************************************
  78. //
  79. // Radio Enumeration
  80. //
  81. // Description:
  82. // This group of APIs enumerates the installed Bluetooth radios.
  83. //
  84. // Sample Usage:
  85. // HANDLE hRadio;
  86. // BLUETOOTH_FIND_RADIO_PARAMS btfrp = { sizeof(btfrp) };
  87. //
  88. // HBLUETOOTH_RADIO_FIND hFind = BluetoothFindFirstRadio( &btfrp, &hRadio );
  89. // if ( NULL != hFind )
  90. // {
  91. // do
  92. // {
  93. // //
  94. // // TODO: Do something with the radio handle.
  95. // //
  96. //
  97. // CloseHandle( hRadio );
  98. //
  99. // } while( BluetoothFindNextRadio( hFind, &hRadio ) );
  100. //
  101. // BluetoothFindRadioClose( hFind );
  102. // }
  103. //
  104. // ***************************************************************************
  105. type
  106. _BLUETOOTH_FIND_RADIO_PARAMS = record
  107. dwSize: DWORD; // IN sizeof this structure
  108. end;
  109. {$EXTERNALSYM _BLUETOOTH_FIND_RADIO_PARAMS}
  110. BLUETOOTH_FIND_RADIO_PARAMS = _BLUETOOTH_FIND_RADIO_PARAMS;
  111. {$EXTERNALSYM BLUETOOTH_FIND_RADIO_PARAMS}
  112. TBlueToothFindRadioParams = BLUETOOTH_FIND_RADIO_PARAMS;
  113. PBlueToothFindRadioParams = ^BLUETOOTH_FIND_RADIO_PARAMS;
  114. HBLUETOOTH_RADIO_FIND = THandle;
  115. {$EXTERNALSYM HBLUETOOTH_RADIO_FIND}
  116. //
  117. // Description:
  118. // Begins the enumeration of local Bluetooth radios.
  119. //
  120. // Parameters:
  121. // pbtfrp
  122. // A pointer to a BLUETOOTH_FIND_RADIO_PARAMS structure. The dwSize
  123. // member of this structure must match the sizeof the of the structure.
  124. //
  125. // phRadio
  126. // A pointer where the first radio HANDLE enumerated will be returned.
  127. //
  128. // Return Values:
  129. // NULL
  130. // Error opening radios or no devices found. Use GetLastError() for
  131. // more info.
  132. //
  133. // ERROR_INVALID_PARAMETER
  134. // pbtfrp parameter is NULL.
  135. //
  136. // ERROR_REVISION_MISMATCH
  137. // The pbtfrp structure is not the right length.
  138. //
  139. // ERROR_OUTOFMEMORY
  140. // Out of memory.
  141. //
  142. // other Win32 errors.
  143. //
  144. // any other
  145. // Success. The return handle is valid and phRadio points to a valid handle.
  146. //
  147. function BluetoothFindFirstRadio(const pbtfrp: PBlueToothFindRadioParams; var phRadio: THandle): HBLUETOOTH_RADIO_FIND; stdcall;
  148. {$EXTERNALSYM BluetoothFindFirstRadio}
  149. //
  150. // Description:
  151. // Finds the next installed Bluetooth radio.
  152. //
  153. // Parameters:
  154. // hFind
  155. // The handle returned by BluetoothFindFirstRadio().
  156. //
  157. // phRadio
  158. // A pointer where the next radio HANDLE enumerated will be returned.
  159. //
  160. // Return Values:
  161. // TRUE
  162. // Next device succesfully found. pHandleOut points to valid handle.
  163. //
  164. // FALSE
  165. // No device found. pHandleOut points to an invalid handle. Call
  166. // GetLastError() for more details.
  167. //
  168. // ERROR_INVALID_HANDLE
  169. // The handle is NULL.
  170. //
  171. // ERROR_NO_MORE_ITEMS
  172. // No more radios found.
  173. //
  174. // ERROR_OUTOFMEMORY
  175. // Out of memory.
  176. //
  177. // other Win32 errors
  178. //
  179. function BluetoothFindNextRadio(hFind: HBLUETOOTH_RADIO_FIND; var phRadio: THandle): BOOL; stdcall;
  180. {$EXTERNALSYM BluetoothFindNextRadio}
  181. //
  182. // Description:
  183. // Closes the enumeration handle.
  184. //
  185. // Parameters
  186. // hFind
  187. // The handle returned by BluetoothFindFirstRadio().
  188. //
  189. // Return Values:
  190. // TRUE
  191. // Handle succesfully closed.
  192. //
  193. // FALSE
  194. // Failure. Check GetLastError() for details.
  195. //
  196. // ERROR_INVALID_HANDLE
  197. // The handle is NULL.
  198. //
  199. function BluetoothFindRadioClose(hFind: HBLUETOOTH_RADIO_FIND): BOOL; stdcall;
  200. {$EXTERNALSYM BluetoothFindRadioClose}
  201. // ***************************************************************************
  202. //
  203. // Radio Information
  204. //
  205. // ***************************************************************************
  206. type
  207. _BLUETOOTH_RADIO_INFO = record
  208. dwSize: DWORD; // Size, in bytes, of this entire data structure
  209. address: BLUETOOTH_ADDRESS; // Address of the local radio
  210. szName: array [0..BLUETOOTH_MAX_NAME_SIZE - 1] of WideChar; // Name of the local radio
  211. ulClassofDevice: ULONG; // Class of device for the local radio
  212. lmpSubversion: Word; // lmpSubversion, manufacturer specifc.
  213. manufacturer: Word; // Manufacturer of the radio, BTH_MFG_Xxx value. For the most up to date
  214. // list, goto the Bluetooth specification website and get the Bluetooth
  215. // assigned numbers document.
  216. end;
  217. {$EXTERNALSYM _BLUETOOTH_RADIO_INFO}
  218. BLUETOOTH_RADIO_INFO = _BLUETOOTH_RADIO_INFO;
  219. {$EXTERNALSYM BLUETOOTH_RADIO_INFO}
  220. PBLUETOOTH_RADIO_INFO = ^BLUETOOTH_RADIO_INFO;
  221. {$EXTERNALSYM PBLUETOOTH_RADIO_INFO}
  222. TBlueToothRadioFind = BLUETOOTH_RADIO_INFO;
  223. PBlueToothRadioFind = PBLUETOOTH_RADIO_INFO;
  224. //
  225. // Description:
  226. // Retrieves the information about the radio represented by the handle.
  227. //
  228. // Parameters:
  229. // hRadio
  230. // Handle to a local radio retrieved through BluetoothFindFirstRadio()
  231. // et al or SetupDiEnumerateDeviceInterfaces()
  232. //
  233. // pRadioInfo
  234. // Radio information to be filled in. The dwSize member must match the
  235. // size of the structure.
  236. //
  237. // Return Values:
  238. // ERROR_SUCCESS
  239. // The information was retrieved successfully.
  240. //
  241. // ERROR_INVALID_PARAMETER
  242. // pRadioInfo or hRadio is NULL.
  243. //
  244. // ERROR_REVISION_MISMATCH
  245. // pRadioInfo->dwSize is invalid.
  246. //
  247. // other Win32 error codes.
  248. //
  249. function BluetoothGetRadioInfo(hRadio: THandle; var pRadioInfo: BLUETOOTH_RADIO_INFO): DWORD; stdcall;
  250. {$EXTERNALSYM BluetoothGetRadioInfo}
  251. // ***************************************************************************
  252. //
  253. // Device Information Stuctures
  254. //
  255. // ***************************************************************************
  256. type
  257. _BLUETOOTH_DEVICE_INFO = record
  258. dwSize: DWORD; // size, in bytes, of this structure - must be the sizeof(BLUETOOTH_DEVICE_INFO)
  259. Address: BLUETOOTH_ADDRESS; // Bluetooth address
  260. ulClassofDevice: ULONG; // Bluetooth "Class of Device"
  261. fConnected: BOOL; // Device connected/in use
  262. fRemembered: BOOL; // Device remembered
  263. fAuthenticated: BOOL; // Device authenticated/paired/bonded
  264. stLastSeen: SYSTEMTIME; // Last time the device was seen
  265. stLastUsed: SYSTEMTIME; // Last time the device was used for other than RNR, inquiry, or SDP
  266. szName: array [0..BLUETOOTH_MAX_NAME_SIZE - 1] of WideChar; // Name of the device
  267. end;
  268. {$EXTERNALSYM _BLUETOOTH_DEVICE_INFO}
  269. BLUETOOTH_DEVICE_INFO = _BLUETOOTH_DEVICE_INFO;
  270. {$EXTERNALSYM BLUETOOTH_DEVICE_INFO}
  271. PBLUETOOTH_DEVICE_INFO = BLUETOOTH_DEVICE_INFO;
  272. {$EXTERNALSYM PBLUETOOTH_DEVICE_INFO}
  273. TBlueToothDeviceInfo = BLUETOOTH_DEVICE_INFO;
  274. PBlueToothDeviceInfo = PBLUETOOTH_DEVICE_INFO;
  275. // ***************************************************************************
  276. //
  277. // Device Enumeration
  278. //
  279. // Description:
  280. // Enumerates the Bluetooth devices. The types of returned device depends
  281. // on the flags set in the BLUETOOTH_DEVICE_SEARCH_PARAMS (see structure
  282. // definition for details).
  283. //
  284. // Sample Usage:
  285. // HBLUETOOTH_DEVICE_FIND hFind;
  286. // BLUETOOTH_DEVICE_SEARCH_PARAMS btsp = { sizeof(btsp) };
  287. // BLUETOOTH_DEVICE_INFO btdi = { sizeof(btdi) };
  288. //
  289. // btsp.fReturnAuthenticated = TRUE;
  290. // btsp.fReturnRemembered = TRUE;
  291. //
  292. // hFind = BluetoothFindFirstDevice( &btsp, &btdi );
  293. // if ( NULL != hFind )
  294. // {
  295. // do
  296. // {
  297. // //
  298. // // TODO: Do something useful with the device info.
  299. // //
  300. //
  301. // } while( BluetoothFindNextDevice( hFind, &btdi ) );
  302. //
  303. // BluetoothFindDeviceClose( hFind );
  304. // }
  305. //
  306. // ***************************************************************************
  307. type
  308. _BLUETOOTH_DEVICE_SEARCH_PARAMS = record
  309. dwSize: DWORD; // IN sizeof this structure
  310. fReturnAuthenticated: BOOL; // IN return authenticated devices
  311. fReturnRemembered: BOOL; // IN return remembered devices
  312. fReturnUnknown: BOOL; // IN return unknown devices
  313. fReturnConnected: BOOL; // IN return connected devices
  314. fIssueInquiry: BOOL; // IN issue a new inquiry
  315. cTimeoutMultiplier: UCHAR; // IN timeout for the inquiry
  316. hRadio: THandle; // IN handle to radio to enumerate - NULL == all radios will be searched
  317. end;
  318. {$EXTERNALSYM _BLUETOOTH_DEVICE_SEARCH_PARAMS}
  319. BLUETOOTH_DEVICE_SEARCH_PARAMS = _BLUETOOTH_DEVICE_SEARCH_PARAMS;
  320. {$EXTERNALSYM BLUETOOTH_DEVICE_SEARCH_PARAMS}
  321. TBlueToothDeviceSearchParams = BLUETOOTH_DEVICE_SEARCH_PARAMS;
  322. HBLUETOOTH_DEVICE_FIND = THandle;
  323. {$EXTERNALSYM HBLUETOOTH_DEVICE_FIND}
  324. //
  325. // Description:
  326. // Begins the enumeration of Bluetooth devices.
  327. //
  328. // Parameters:
  329. // pbtsp
  330. // A pointer to a BLUETOOTH_DEVICE_SEARCH_PARAMS structure. This
  331. // structure contains the flags and inputs used to conduct the search.
  332. // See BLUETOOTH_DEVICE_SEARCH_PARAMS for details.
  333. //
  334. // pbtdi
  335. // A pointer to a BLUETOOTH_DEVICE_INFO structure to return information
  336. // about the first Bluetooth device found. Note that the dwSize member
  337. // of the structure must be the sizeof(BLUETOOTH_DEVICE_INFO) before
  338. // calling because the APIs hast to know the size of the buffer being
  339. // past in. The dwSize member must also match the exact
  340. // sizeof(BLUETOOTH_DEVICE_INFO) or the call will fail.
  341. //
  342. // Return Values:
  343. // NULL
  344. // Error opening radios or not devices found. Use GetLastError for more info.
  345. //
  346. // ERROR_INVALID_PARAMETER
  347. // pbtsp parameter or pbtdi parameter is NULL.
  348. //
  349. // ERROR_REVISION_MISMATCH
  350. // The pbtfrp structure is not the right length.
  351. //
  352. // other Win32 errors
  353. //
  354. // any other value
  355. // Success. The return handle is valid and pbtdi points to valid data.
  356. //
  357. function BluetoothFindFirstDevice(const pbtsp: BLUETOOTH_DEVICE_SEARCH_PARAMS; var pbtdi: BLUETOOTH_DEVICE_INFO): HBLUETOOTH_DEVICE_FIND; stdcall;
  358. {$EXTERNALSYM BluetoothFindFirstDevice}
  359. //
  360. // Description:
  361. // Finds the next Bluetooth device in the enumeration.
  362. //
  363. // Parameters:
  364. // hFind
  365. // The handle returned from BluetoothFindFirstDevice().
  366. //
  367. // pbtdi
  368. // A pointer to a BLUETOOTH_DEVICE_INFO structure to return information
  369. // about the first Bluetooth device found. Note that the dwSize member
  370. // of the structure must be the sizeof(BLUETOOTH_DEVICE_INFO) before
  371. // calling because the APIs hast to know the size of the buffer being
  372. // past in. The dwSize member must also match the exact
  373. // sizeof(BLUETOOTH_DEVICE_INFO) or the call will fail.
  374. //
  375. // Return Values:
  376. // TRUE
  377. // Next device succesfully found. pHandleOut points to valid handle.
  378. //
  379. // FALSE
  380. // No device found. pHandleOut points to an invalid handle. Call
  381. // GetLastError() for more details.
  382. //
  383. // ERROR_INVALID_HANDLE
  384. // The handle is NULL.
  385. //
  386. // ERROR_NO_MORE_ITEMS
  387. // No more radios found.
  388. //
  389. // ERROR_OUTOFMEMORY
  390. // Out of memory.
  391. //
  392. // other Win32 errors
  393. //
  394. function BluetoothFindNextDevice(hFind: HBLUETOOTH_DEVICE_FIND; var pbtdi: BLUETOOTH_DEVICE_INFO): BOOL; stdcall;
  395. {$EXTERNALSYM BluetoothFindNextDevice}
  396. //
  397. // Description:
  398. // Closes the enumeration handle.
  399. //
  400. // Parameters:
  401. // hFind
  402. // The handle returned from BluetoothFindFirstDevice().
  403. //
  404. // Return Values:
  405. // TRUE
  406. // Handle succesfully closed.
  407. //
  408. // FALSE
  409. // Failure. Check GetLastError() for details.
  410. //
  411. // ERROR_INVALID_HANDLE
  412. // The handle is NULL.
  413. //
  414. function BluetoothFindDeviceClose(hFind: HBLUETOOTH_DEVICE_FIND): BOOL; stdcall;
  415. {$EXTERNALSYM BluetoothFindDeviceClose}
  416. //
  417. // Description:
  418. // Retrieves information about a remote device.
  419. //
  420. // Fill in the dwSize and the Address members of the pbtdi structure
  421. // being passed in. On success, the rest of the members will be filled
  422. // out with the information that the system knows.
  423. //
  424. // Parameters:
  425. // hRadio
  426. // Handle to a local radio retrieved through BluetoothFindFirstRadio()
  427. // et al or SetupDiEnumerateDeviceInterfaces()
  428. //
  429. // pbtdi
  430. // A pointer to a BLUETOOTH_DEVICE_INFO structure to return information
  431. // about the first Bluetooth device found. The dwSize member of the
  432. // structure must be the sizeof the structure in bytes. The Address
  433. // member must be filled out with the Bluetooth address of the remote
  434. // device.
  435. //
  436. // Return Values:
  437. // ERROR_SUCCESS
  438. // Success. Information returned.
  439. //
  440. // ERROR_REVISION_MISMATCH
  441. // The size of the BLUETOOTH_DEVICE_INFO isn't compatible. Check
  442. // the dwSize member of the BLUETOOTH_DEVICE_INFO structure you
  443. // passed in.
  444. //
  445. // ERROR_NOT_FOUND
  446. // The radio is not known by the system or the Address field of
  447. // the BLUETOOTH_DEVICE_INFO structure is all zeros.
  448. //
  449. // ERROR_INVALID_PARAMETER
  450. // pbtdi is NULL.
  451. //
  452. // other error codes
  453. //
  454. function BluetoothGetDeviceInfo(hRadio: THandle; var pbtdi: BLUETOOTH_DEVICE_INFO): DWORD; stdcall;
  455. {$EXTERNALSYM BluetoothGetDeviceInfo}
  456. //
  457. // Description:
  458. // Updates the computer local cache about the device.
  459. //
  460. // Parameters:
  461. // pbtdi
  462. // A pointer to the BLUETOOTH_DEVICE_INFO structure to be updated.
  463. // The following members must be valid:
  464. // dwSize
  465. // Must match the size of the structure.
  466. // Address
  467. // Must be a previously found radio address.
  468. // szName
  469. // New name to be stored.
  470. //
  471. // Return Values:
  472. // ERROR_SUCCESS
  473. // The device information was updated successfully.
  474. //
  475. // ERROR_INVALID_PARAMETER
  476. // pbtdi is NULL.
  477. //
  478. // ERROR_REVISION_MISMATCH
  479. // pbtdi->dwSize is invalid.
  480. //
  481. // other Win32 error codes.
  482. //
  483. function BluetoothUpdateDeviceRecord(var pbtdi: BLUETOOTH_DEVICE_INFO): DWORD; stdcall;
  484. {$EXTERNALSYM BluetoothUpdateDeviceRecord}
  485. //
  486. // Description:
  487. // Delete the authentication (aka "bond") between the computer and the
  488. // device. Also purges any cached information about the device.
  489. //
  490. // Return Values:
  491. // ERROR_SUCCESS
  492. // The device was removed successfully.
  493. //
  494. // ERROR_NOT_FOUND
  495. // The device was not found. If no Bluetooth radio is installed,
  496. // the devices could not be enumerated or removed.
  497. //
  498. function BluetoothRemoveDevice(var pAddress: BLUETOOTH_ADDRESS): DWORD; stdcall;
  499. {$EXTERNALSYM BluetoothRemoveDevice}
  500. // ***************************************************************************
  501. //
  502. // Device Picker Dialog
  503. //
  504. // Description:
  505. // Invokes a common dialog for selecting Bluetooth devices. The list
  506. // of devices displayed to the user is determined by the flags and
  507. // settings the caller specifies in the BLUETOOTH_SELECT_DEVICE_PARAMS
  508. // (see structure definition for more details).
  509. //
  510. // If BluetoothSelectDevices() returns TRUE, the caller must call
  511. // BluetoothSelectDevicesFree() or memory will be leaked within the
  512. // process.
  513. //
  514. // Sample Usage:
  515. //
  516. // BLUETOOTH_SELECT_DEVICE_PARAMS btsdp = { sizeof(btsdp) };
  517. //
  518. // btsdp.hwndParent = hDlg;
  519. // btsdp.fShowUnknown = TRUE;
  520. // btsdp.fAddNewDeviceWizard = TRUE;
  521. //
  522. // BOOL b = BluetoothSelectDevices( &btsdp );
  523. // if ( b )
  524. // {
  525. // BLUETOOTH_DEVICE_INFO * pbtdi = btsdp.pDevices;
  526. // for ( ULONG cDevice = 0; cDevice < btsdp.cNumDevices; cDevice ++ )
  527. // {
  528. // if ( pbtdi->fAuthenticated || pbtdi->fRemembered )
  529. // {
  530. // //
  531. // // TODO: Do something usefull with the device info
  532. // //
  533. // }
  534. //
  535. // pbtdi = (BLUETOOTH_DEVICE_INFO *) ((LPBYTE)pbtdi + pbtdi->dwSize);
  536. // }
  537. //
  538. // BluetoothSelectDevicesFree( &btsdp );
  539. // }
  540. //
  541. // ***************************************************************************
  542. type
  543. _BLUETOOTH_COD_PAIRS = record
  544. ulCODMask: ULONG; // ClassOfDevice mask to compare
  545. pcszDescription: LPWSTR; // Descriptive string of mask
  546. end;
  547. {$EXTERNALSYM _BLUETOOTH_COD_PAIRS}
  548. BLUETOOTH_COD_PAIRS = _BLUETOOTH_COD_PAIRS;
  549. {$EXTERNALSYM BLUETOOTH_COD_PAIRS}
  550. TBlueToothCodPairs = BLUETOOTH_COD_PAIRS;
  551. PBlueToothCodPairs = ^BLUETOOTH_COD_PAIRS;
  552. PFN_DEVICE_CALLBACK = function(pvParam: Pointer; pDevice: PBLUETOOTH_DEVICE_INFO): BOOL; stdcall;
  553. {$EXTERNALSYM PFN_DEVICE_CALLBACK}
  554. _BLUETOOTH_SELECT_DEVICE_PARAMS = record
  555. dwSize: DWORD; // IN sizeof this structure
  556. cNumOfClasses: ULONG; // IN Number in prgClassOfDevice - if ZERO search for all devices
  557. prgClassOfDevices: PBlueToothCodPairs; // IN Array of CODs to find.
  558. pszInfo: LPWSTR; // IN If not NULL, sets the "information" text
  559. hwndParent: HWND; // IN parent window - NULL == no parent
  560. fForceAuthentication: BOOL; // IN If TRUE, authenication will be forced before returning
  561. fShowAuthenticated: BOOL; // IN If TRUE, authenticated devices will be shown in the picker
  562. fShowRemembered: BOOL; // IN If TRUE, remembered devices will be shown in the picker
  563. fShowUnknown: BOOL; // IN If TRUE, unknown devices that are not authenticated or "remember" will be shown.
  564. fAddNewDeviceWizard: BOOL; // IN If TRUE, invokes the add new device wizard.
  565. fSkipServicesPage: BOOL; // IN If TRUE, skips the "Services" page in the wizard.
  566. pfnDeviceCallback: PFN_DEVICE_CALLBACK; // IN If non-NULL, a callback that will be called for each device. If the
  567. // the callback returns TRUE, the item will be added. If the callback is
  568. // is FALSE, the item will not be shown.
  569. pvParam: Pointer; // IN Parameter to be passed to pfnDeviceCallback as the pvParam.
  570. cNumDevices: DWORD; // IN number calles wants - ZERO == no limit.
  571. // OUT the number of devices returned.
  572. pDevices: PBLUETOOTH_DEVICE_INFO; // OUT pointer to an array for BLUETOOTH_DEVICE_INFOs.
  573. // call BluetoothSelectDevicesFree() to free
  574. end;
  575. {$EXTERNALSYM _BLUETOOTH_SELECT_DEVICE_PARAMS}
  576. BLUETOOTH_SELECT_DEVICE_PARAMS = _BLUETOOTH_SELECT_DEVICE_PARAMS;
  577. {$EXTERNALSYM BLUETOOTH_SELECT_DEVICE_PARAMS}
  578. TBlueToothSelectDeviceParams = BLUETOOTH_SELECT_DEVICE_PARAMS;
  579. PBlueToothSelectDeviceParams = ^BLUETOOTH_SELECT_DEVICE_PARAMS;
  580. //
  581. // Description:
  582. // (See header above)
  583. //
  584. // Return Values:
  585. // TRUE
  586. // User selected a device. pbtsdp->pDevices points to valid data.
  587. // Caller should check the fAuthenticated && fRemembered flags to
  588. // determine which devices we successfuly authenticated or valid
  589. // selections by the user.
  590. //
  591. // Use BluetoothSelectDevicesFree() to free the nessecary data
  592. // such as pDevices only if this function returns TRUE.
  593. //
  594. // FALSE
  595. // No valid data returned. Call GetLastError() for possible details
  596. // of the failure. If GLE() is:
  597. //
  598. // ERROR_CANCELLED
  599. // The user cancelled the request.
  600. //
  601. // ERROR_INVALID_PARAMETER
  602. // The pbtsdp is NULL.
  603. //
  604. // ERROR_REVISION_MISMATCH
  605. // The structure passed in as pbtsdp is of an unknown size.
  606. //
  607. // other WIN32 errors
  608. //
  609. function BluetoothSelectDevices(pbtsdp: PBlueToothSelectDeviceParams): BOOL; stdcall;
  610. {$EXTERNALSYM BluetoothSelectDevices}
  611. //
  612. // Description:
  613. // This function should only be called if BluetoothSelectDevices() returns
  614. // TRUE. This function will free any memory and resource returned by the
  615. // BluetoothSelectDevices() in the BLUETOOTH_SELECT_DEVICE_PARAMS
  616. // structure.
  617. //
  618. // Return Values:
  619. // TRUE
  620. // Success.
  621. //
  622. // FALSE
  623. // Nothing to free.
  624. //
  625. function BluetoothSelectDevicesFree(pbtsdp: PBlueToothSelectDeviceParams): BOOL; stdcall;
  626. {$EXTERNALSYM BluetoothSelectDevicesFree}
  627. // ***************************************************************************
  628. //
  629. // Device Property Sheet
  630. //
  631. // ***************************************************************************
  632. //
  633. // Description:
  634. // Invokes the CPLs device info property sheet.
  635. //
  636. // Parameters:
  637. // hwndParent
  638. // HWND to parent the property sheet.
  639. //
  640. // pbtdi
  641. // A pointer to a BLUETOOTH_DEVICE_INFO structure of the device
  642. // to be displayed.
  643. //
  644. // Return Values:
  645. // TRUE
  646. // The property page was successfully displayed.
  647. //
  648. // FALSE
  649. // Failure. The property page was not displayed. Check GetLastError
  650. // for more details.
  651. //
  652. function BluetoothDisplayDeviceProperties(hwndParent: HWND; pbtdi: PBLUETOOTH_DEVICE_INFO): BOOL; stdcall;
  653. {$EXTERNALSYM BluetoothDisplayDeviceProperties}
  654. // ***************************************************************************
  655. //
  656. // Radio Authentication
  657. //
  658. // ***************************************************************************
  659. //
  660. // Description:
  661. // Sends an authentication request to a remote device.
  662. //
  663. // There are two modes of operation. "Wizard mode" and "Blind mode."
  664. //
  665. // "Wizard mode" is invoked when the pszPasskey is NULL. This will cause
  666. // the "Bluetooth Connection Wizard" to be invoked. The user will be
  667. // prompted to enter a passkey during the wizard after which the
  668. // authentication request will be sent. The user will see the success
  669. // or failure of the authentication attempt. The user will also be
  670. // given the oppurtunity to try to fix a failed authentication.
  671. //
  672. // "Blind mode" is invoked when the pszPasskey is non-NULL. This will
  673. // cause the computer to send a authentication request to the remote
  674. // device. No UI is ever displayed. The Bluetooth status code will be
  675. // mapped to a Win32 Error code.
  676. //
  677. // Parameters:
  678. //
  679. // hwndParent
  680. // The window to parent the authentication wizard. If NULL, the
  681. // wizard will be parented off the desktop.
  682. //
  683. // hRadio
  684. // A valid local radio handle or NULL. If NULL, then all radios will
  685. // be tired. If any of the radios succeed, then the call will
  686. // succeed.
  687. //
  688. // pbtdi
  689. // BLUETOOTH_DEVICE_INFO record of the device to be authenticated.
  690. //
  691. // pszPasskey
  692. // PIN to be used to authenticate the device. If NULL, then UI is
  693. // displayed and the user steps through the authentication process.
  694. // If not NULL, no UI is shown. The passkey is NOT NULL terminated.
  695. //
  696. // ulPasskeyLength
  697. // Length of szPassKey in bytes. The length must be less than or
  698. // equal to BLUETOOTH_MAX_PASSKEY_SIZE * sizeof(WCHAR).
  699. //
  700. // Return Values:
  701. //
  702. // ERROR_SUCCESS
  703. // Success.
  704. //
  705. // ERROR_CANCELLED
  706. // User aborted the operation.
  707. //
  708. // ERROR_INVALID_PARAMETER
  709. // The device structure in pbtdi is invalid.
  710. //
  711. // ERROR_NO_MORE_ITEMS
  712. // The device in pbtdi is already been marked as authenticated.
  713. //
  714. // other WIN32 error
  715. // Failure. Return value is the error code.
  716. //
  717. // For "Blind mode," here is the current mapping of Bluetooth status
  718. // code to Win32 error codes:
  719. //
  720. // { BTH_ERROR_SUCCESS, ERROR_SUCCESS },
  721. // { BTH_ERROR_NO_CONNECTION, ERROR_DEVICE_NOT_CONNECTED },
  722. // { BTH_ERROR_PAGE_TIMEOUT, WAIT_TIMEOUT },
  723. // { BTH_ERROR_HARDWARE_FAILURE, ERROR_GEN_FAILURE },
  724. // { BTH_ERROR_AUTHENTICATION_FAILURE, ERROR_NOT_AUTHENTICATED },
  725. // { BTH_ERROR_MEMORY_FULL, ERROR_NOT_ENOUGH_MEMORY },
  726. // { BTH_ERROR_CONNECTION_TIMEOUT, WAIT_TIMEOUT },
  727. // { BTH_ERROR_LMP_RESPONSE_TIMEOUT, WAIT_TIMEOUT },
  728. // { BTH_ERROR_MAX_NUMBER_OF_CONNECTIONS, ERROR_REQ_NOT_ACCEP },
  729. // { BTH_ERROR_PAIRING_NOT_ALLOWED, ERROR_ACCESS_DENIED },
  730. // { BTH_ERROR_UNSPECIFIED_ERROR, ERROR_NOT_READY },
  731. // { BTH_ERROR_LOCAL_HOST_TERMINATED_CONNECTION, ERROR_VC_DISCONNECTED },
  732. //
  733. function BluetoothAuthenticateDevice(
  734. hwndParent: HWND;
  735. hRadio: THandle;
  736. pbtbi: PBLUETOOTH_DEVICE_INFO;
  737. pszPasskey: PWideChar;
  738. ulPasskeyLength: ULONG): DWORD; stdcall;
  739. {$EXTERNALSYM BluetoothAuthenticateDevice}
  740. //
  741. // Description:
  742. // Allows the caller to prompt for multiple devices to be authenticated
  743. // within a single instance of the "Bluetooth Connection Wizard."
  744. //
  745. // Parameters:
  746. //
  747. // hwndParent
  748. // The window to parent the authentication wizard. If NULL, the
  749. // wizard will be parented off the desktop.
  750. //
  751. // hRadio
  752. // A valid local radio handle or NULL. If NULL, then all radios will
  753. // be tired. If any of the radios succeed, then the call will
  754. // succeed.
  755. //
  756. // cDevices
  757. // Number of devices in the rgbtdi array.
  758. //
  759. // rgbtdi
  760. // An array BLUETOOTH_DEVICE_INFO records of the devices to be
  761. // authenticated.
  762. //
  763. // Return Values:
  764. //
  765. // ERROR_SUCCESS
  766. // Success. Check the fAuthenticate flag on each of the devices.
  767. //
  768. // ERROR_CANCELLED
  769. // User aborted the operation. Check the fAuthenticate flags on
  770. // each device to determine if any of the devices were authenticated
  771. // before the user cancelled the operation.
  772. //
  773. // ERROR_INVALID_PARAMETER
  774. // One of the items in the array of devices is invalid.
  775. //
  776. // ERROR_NO_MORE_ITEMS
  777. // All the devices in the array of devices are already been marked as
  778. // being authenticated.
  779. //
  780. // other WIN32 error
  781. // Failure. Return value is the error code.
  782. //
  783. function BluetoothAuthenticateMultipleDevices(
  784. hwndParent: HWND;
  785. hRadio: THandle;
  786. cDevices: DWORD;
  787. pbtdi: PBLUETOOTH_DEVICE_INFO): DWORD; stdcall;
  788. {$EXTERNALSYM BluetoothAuthenticateMultipleDevices}
  789. // ***************************************************************************
  790. //
  791. // Bluetooth Services
  792. //
  793. // ***************************************************************************
  794. const
  795. BLUETOOTH_SERVICE_DISABLE = $00;
  796. {$EXTERNALSYM BLUETOOTH_SERVICE_DISABLE}
  797. BLUETOOTH_SERVICE_ENABLE = $01;
  798. {$EXTERNALSYM BLUETOOTH_SERVICE_ENABLE}
  799. BLUETOOTH_SERVICE_MASK = BLUETOOTH_SERVICE_ENABLE or BLUETOOTH_SERVICE_DISABLE;
  800. {$EXTERNALSYM BLUETOOTH_SERVICE_MASK}
  801. //
  802. // Description:
  803. // Enables/disables the services for a particular device.
  804. //
  805. // The system maintains a mapping of service guids to supported drivers for
  806. // Bluetooth-enabled devices. Enabling a service installs the corresponding
  807. // device driver. Disabling a service removes the corresponding device driver.
  808. //
  809. // If a non-supported service is enabled, a driver will not be installed.
  810. //
  811. // Parameters
  812. // hRadio
  813. // Handle of the local Bluetooth radio device.
  814. //
  815. // pbtdi
  816. // Pointer to a BLUETOOTH_DEVICE_INFO record.
  817. //
  818. // pGuidService
  819. // The service GUID on the remote device.
  820. //
  821. // dwServiceFlags
  822. // Flags to adjust the service.
  823. // BLUETOOTH_SERVICE_DISABLE - disable the service
  824. // BLUETOOTH_SERVICE_ENABLE - enables the service
  825. //
  826. // Return Values:
  827. // ERROR_SUCCESS
  828. // The call was successful.
  829. //
  830. // ERROR_INVALID_PARAMETER
  831. // dwServiceFlags are invalid.
  832. //
  833. // ERROR_SERVICE_DOES_NOT_EXIST
  834. // The GUID in pGuidService is not supported.
  835. //
  836. // other WIN32 error
  837. // The call failed.
  838. //
  839. function BluetoothSetServiceState(
  840. hRadio: THandle;
  841. pbtdi: PBLUETOOTH_DEVICE_INFO;
  842. const pGuidService: TGUID;
  843. dwServiceFlags: DWORD): DWORD; stdcall;
  844. {$EXTERNALSYM BluetoothSetServiceState}
  845. //
  846. // Description:
  847. // Enumerates the services guids enabled on a particular device. If hRadio
  848. // is NULL, all device will be searched for the device and all the services
  849. // enabled will be returned.
  850. //
  851. // Parameters:
  852. // hRadio
  853. // Handle of the local Bluetooth radio device. If NULL, it will search
  854. // all the radios for the address in the pbtdi.
  855. //
  856. // pbtdi
  857. // Pointer to a BLUETOOTH_DEVICE_INFO record.
  858. //
  859. // pcService
  860. // On input, the number of records pointed to by pGuidServices.
  861. // On output, the number of valid records return in pGuidServices.
  862. //
  863. // pGuidServices
  864. // Pointer to memory that is at least *pcService in length.
  865. //
  866. // Return Values:
  867. // ERROR_SUCCESS
  868. // The call succeeded. pGuidServices is valid.
  869. //
  870. // ERROR_MORE_DATA
  871. // The call succeeded. pGuidService contains an incomplete list of
  872. // enabled service GUIDs.
  873. //
  874. // other WIN32 errors
  875. // The call failed.
  876. //
  877. function BluetoothEnumerateInstalledServices(
  878. hRadio: THandle;
  879. pbtdi: PBLUETOOTH_DEVICE_INFO;
  880. var pcServices: DWORD;
  881. pGuidServices: PGUID): DWORD; stdcall;
  882. {$EXTERNALSYM BluetoothEnumerateInstalledServices}
  883. //
  884. // Description:
  885. // Change the discovery state of the local radio(s).
  886. // If hRadio is NULL, all the radios will be set.
  887. //
  888. // Use BluetoothIsDiscoverable() to determine the radios current state.
  889. //
  890. // The system ensures that a discoverable system is connectable, thus
  891. // the radio must allow incoming connections (see
  892. // BluetoothEnableIncomingConnections) prior to making a radio
  893. // discoverable. Failure to do so will result in this call failing
  894. // (returns FALSE).
  895. //
  896. // Parameters:
  897. // hRadio
  898. // If not NULL, changes the state of a specific radio.
  899. // If NULL, the API will interate through all the radios.
  900. //
  901. // fEnabled
  902. // If FALSE, discovery will be disabled.
  903. //
  904. // Return Values
  905. // TRUE
  906. // State was successfully changed. If the caller specified NULL for
  907. // hRadio, at least of the radios accepted the state change.
  908. //
  909. // FALSE
  910. // State was not changed. If the caller specified NULL for hRadio, all
  911. // of the radios did not accept the state change.
  912. //
  913. function BluetoothEnableDiscovery(hRadio: THandle; fEnabled: BOOL): BOOL; stdcall;
  914. {$EXTERNALSYM BluetoothEnableDiscovery}
  915. //
  916. // Description:
  917. // Determines if the Bluetooth radios are discoverable. If there are
  918. // multiple radios, the first one to say it is discoverable will cause
  919. // this function to return TRUE.
  920. //
  921. // Parameters:
  922. // hRadio
  923. // Handle of the radio to check. If NULL, it will check all local
  924. // radios.
  925. //
  926. // Return Values:
  927. // TRUE
  928. // A least one radio is discoverable.
  929. //
  930. // FALSE
  931. // No radios are discoverable.
  932. //
  933. function BluetoothIsDiscoverable(hRadio: THandle): BOOL; stdcall;
  934. {$EXTERNALSYM BluetoothIsDiscoverable}
  935. //
  936. // Description:
  937. // Enables/disables the state of a radio to accept incoming connections.
  938. // If hRadio is NULL, all the radios will be set.
  939. //
  940. // Use BluetoothIsConnectable() to determine the radios current state.
  941. //
  942. // The system enforces that a radio that is not connectable is not
  943. // discoverable too. The radio must be made non-discoverable (see
  944. // BluetoothEnableDiscovery) prior to making a radio non-connectionable.
  945. // Failure to do so will result in this call failing (returns FALSE).
  946. //
  947. // Parameters:
  948. // hRadio
  949. // If not NULL, changes the state of a specific radio.
  950. // If NULL, the API will interate through all the radios.
  951. //
  952. // fEnabled
  953. // If FALSE, incoming connection will be disabled.
  954. //
  955. // Return Values
  956. // TRUE
  957. // State was successfully changed. If the caller specified NULL for
  958. // hRadio, at least of the radios accepted the state change.
  959. //
  960. // FALSE
  961. // State was not changed. If the caller specified NULL for hRadio, all
  962. // of the radios did not accept the state change.
  963. //
  964. function BluetoothEnableIncomingConnections(hRadio: THandle; fEnabled: BOOL): BOOL; stdcall;
  965. {$EXTERNALSYM BluetoothEnableIncomingConnections}
  966. //
  967. // Description:
  968. // Determines if the Bluetooth radios are connectable. If there are
  969. // multiple radios, the first one to say it is connectable will cause
  970. // this function to return TRUE.
  971. //
  972. // Parameters:
  973. // hRadio
  974. // Handle of the radio to check. If NULL, it will check all local
  975. // radios.
  976. //
  977. // Return Values:
  978. // TRUE
  979. // A least one radio is allowing incoming connections.
  980. //
  981. // FALSE
  982. // No radios are allowing incoming connections.
  983. //
  984. function BluetoothIsConnectable(hRadio: THandle): BOOL; stdcall;
  985. {$EXTERNALSYM BluetoothIsConnectable}
  986. // ***************************************************************************
  987. //
  988. // Authentication Registration
  989. //
  990. // ***************************************************************************
  991. type
  992. HBLUETOOTH_AUTHENTICATION_REGISTRATION = THandle;
  993. {$EXTERNALSYM HBLUETOOTH_AUTHENTICATION_REGISTRATION}
  994. PFN_AUTHENTICATION_CALLBACK = function(pvParam: Pointer; pDevice: PBLUETOOTH_DEVICE_INFO): BOOL; stdcall;
  995. {$EXTERNALSYM PFN_AUTHENTICATION_CALLBACK}
  996. //
  997. // Description:
  998. // Registers a callback function to be called when a particular device
  999. // requests authentication. The request is sent to the last application
  1000. // that requested authentication for a particular device.
  1001. //
  1002. // Parameters:
  1003. // pbtdi
  1004. // A pointer to a BLUETOOTH_DEVICE_INFO structure. The Bluetooth
  1005. // address will be used for comparision.
  1006. //
  1007. // phRegHandle
  1008. // A pointer to where the registration HANDLE value will be
  1009. // stored. Call BluetoothUnregisterAuthentication() to close
  1010. // the handle.
  1011. //
  1012. // pfnCallback
  1013. // The function that will be called when the authentication event
  1014. // occurs. This function should match PFN_AUTHENTICATION_CALLBACK's
  1015. // prototype.
  1016. //
  1017. // pvParam
  1018. // Optional parameter to be past through to the callback function.
  1019. // This can be anything the application was to define.
  1020. //
  1021. // Return Values:
  1022. // ERROR_SUCCESS
  1023. // Success. A valid registration handle was returned.
  1024. //
  1025. // ERROR_OUTOFMEMORY
  1026. // Out of memory.
  1027. //
  1028. // other Win32 error.
  1029. // Failure. The registration handle is invalid.
  1030. //
  1031. function BluetoothRegisterForAuthentication(
  1032. pbtdi: PBLUETOOTH_DEVICE_INFO;
  1033. var phRegHandle: HBLUETOOTH_AUTHENTICATION_REGISTRATION;
  1034. pfnCallback: PFN_AUTHENTICATION_CALLBACK;
  1035. pvParam: Pointer): DWORD; stdcall;
  1036. {$EXTERNALSYM BluetoothRegisterForAuthentication}
  1037. //
  1038. // Description:
  1039. // Unregisters an authentication callback and closes the handle. See
  1040. // BluetoothRegisterForAuthentication() for more information about
  1041. // authentication registration.
  1042. //
  1043. // Parameters:
  1044. // hRegHandle
  1045. // Handle returned by BluetoothRegisterForAuthentication().
  1046. //
  1047. // Return Value:
  1048. // TRUE
  1049. // The handle was successfully closed.
  1050. //
  1051. // FALSE
  1052. // The handle was not successfully closed. Check GetLastError for
  1053. // more details.
  1054. //
  1055. // ERROR_INVALID_HANDLE
  1056. // The handle is NULL.
  1057. //
  1058. // other Win32 errors.
  1059. //
  1060. function BluetoothUnregisterAuthentication(hRegHandle: HBLUETOOTH_AUTHENTICATION_REGISTRATION): BOOL; stdcall;
  1061. {$EXTERNALSYM BluetoothUnregisterAuthentication}
  1062. //
  1063. // Description:
  1064. // This function should be called after receiving an authentication request
  1065. // to send the passkey response.
  1066. //
  1067. // Parameters:
  1068. //
  1069. // hRadio
  1070. // Optional handle to the local radio. If NULL, the function will try
  1071. // each radio until one succeeds.
  1072. //
  1073. // pbtdi
  1074. // A pointer to a BLUETOOTH_DEVICE_INFO structure describing the device
  1075. // being authenticated. This can be the same structure passed to the
  1076. // callback function.
  1077. //
  1078. // pszPasskey
  1079. // A pointer to UNICODE zero-terminated string of the passkey response
  1080. // that should be sent back to the authenticating device.
  1081. //
  1082. // Return Values:
  1083. // ERROR_SUCESS
  1084. // The device accepted the passkey response. The device is authenticated.
  1085. //
  1086. // ERROR_CANCELED
  1087. // The device denied the passkey reponse. This also will returned if there
  1088. // is a communications problem with the local radio.
  1089. //
  1090. // E_FAIL
  1091. // The device returned a failure code during authentication.
  1092. //
  1093. // other Win32 error codes
  1094. //
  1095. function BluetoothSendAuthenticationResponse(
  1096. hRadio: THandle;
  1097. pbtdi: PBLUETOOTH_DEVICE_INFO;
  1098. pszPasskey: LPWSTR): DWORD; stdcall;
  1099. {$EXTERNALSYM BluetoothSendAuthenticationResponse}
  1100. // ***************************************************************************
  1101. //
  1102. // SDP Parsing Functions
  1103. //
  1104. // ***************************************************************************
  1105. type
  1106. TSpdElementDataString = record
  1107. // raw string buffer, may not be encoded as ANSI, use
  1108. // BluetoothSdpGetString to convert the value if it is described
  1109. // by the base language attribute ID list
  1110. value: PBYTE;
  1111. // raw length of the string, may not be NULL terminuated
  1112. length: ULONG;
  1113. end;
  1114. TSpdElementDataUrl = record
  1115. value: PBYTE;
  1116. length: ULONG;
  1117. end;
  1118. // type == SDP_TYPE_SEQUENCE
  1119. TSpdElementDataSequence = record
  1120. // raw sequence, starts at sequence element header
  1121. value: PBYTE;
  1122. // raw sequence length
  1123. length: ULONG;
  1124. end;
  1125. // type == SDP_TYPE_ALTERNATIVE
  1126. TSpdElementDataAlternative = record
  1127. // raw alternative, starts at alternative element header
  1128. value: PBYTE;
  1129. // raw alternative length
  1130. length: ULONG;
  1131. end;
  1132. _SDP_ELEMENT_DATA = record
  1133. //
  1134. // Enumeration of SDP element types. Generic element types will have a
  1135. // specificType value other then SDP_ST_NONE. The generic types are:
  1136. // o SDP_TYPE_UINT
  1137. // o SDP_TYPE_INT
  1138. // o SDP_TYPE_UUID
  1139. //
  1140. type_: SDP_TYPE;
  1141. //
  1142. // Specific types for the generic SDP element types.
  1143. //
  1144. specificType: SDP_SPECIFICTYPE;
  1145. //
  1146. // Union of all possible data types. type and specificType will indicate
  1147. // which field is valid. For types which do not have a valid specificType,
  1148. // specific type will be SDP_ST_NONE.
  1149. //
  1150. case Integer of
  1151. // type == SDP_TYPE_INT
  1152. 0: (int128: SDP_LARGE_INTEGER_16); // specificType == SDP_ST_INT128
  1153. 1: (int64: LONGLONG); // specificType == SDP_ST_INT64
  1154. 2: (int32: Integer); // specificType == SDP_ST_INT32
  1155. 3: (int16: SHORT); // specificType == SDP_ST_INT16
  1156. 4: (int8: CHAR); // specificType == SDP_ST_INT8
  1157. // type == SDP_TYPE_UINT
  1158. 5: (uint128: SDP_ULARGE_INTEGER_16); // specificType == SDP_ST_UINT128
  1159. 6: (uint64: Int64); // specificType == SDP_ST_UINT64
  1160. 7: (uint32: ULONG); // specificType == SDP_ST_UINT32
  1161. 8: (uint16: Word); // specificType == SDP_ST_UINT16
  1162. 9: (uint8: UCHAR); // specificType == SDP_ST_UINT8
  1163. // type == SDP_TYPE_BOOLEAN
  1164. 10: (booleanVal: UCHAR);
  1165. // type == SDP_TYPE_UUID
  1166. 11: (uuid128: TGUID); // specificType == SDP_ST_UUID128
  1167. 12: (uuid32: ULONG); // specificType == SDP_ST_UUID32
  1168. 13: (uuid16: Word); // specificType == SDP_ST_UUID32
  1169. // type == SDP_TYPE_STRING
  1170. 14: (string_: TSpdElementDataString);
  1171. // type == SDP_TYPE_URL
  1172. 15: (url: TSpdElementDataUrl);
  1173. // type == SDP_TYPE_SEQUENCE
  1174. 16: (sequence: TSpdElementDataSequence);
  1175. // type == SDP_TYPE_ALTERNATIVE
  1176. 17: (alternative: TSpdElementDataAlternative);
  1177. end;
  1178. {$EXTERNALSYM _SDP_ELEMENT_DATA}
  1179. SDP_ELEMENT_DATA = _SDP_ELEMENT_DATA;
  1180. {$EXTERNALSYM SDP_ELEMENT_DATA}
  1181. PSDP_ELEMENT_DATA = ^SDP_ELEMENT_DATA;
  1182. {$EXTERNALSYM PSDP_ELEMENT_DATA}
  1183. TSdpElementData = SDP_ELEMENT_DATA;
  1184. PSdpElementData = PSDP_ELEMENT_DATA;
  1185. //
  1186. // Description:
  1187. // Retrieves and parses the element found at pSdpStream
  1188. //
  1189. // Parameters:
  1190. // IN pSdpStream
  1191. // pointer to valid SDP stream
  1192. //
  1193. // IN cbSdpStreamLength
  1194. // length of pSdpStream in bytes
  1195. //
  1196. // OUT pData
  1197. // pointer to be filled in with the data of the SDP element at the
  1198. // beginning of pSdpStream
  1199. //
  1200. // Return Values:
  1201. // ERROR_INVALID_PARAMETER
  1202. // one of required parameters is NULL or the pSdpStream is invalid
  1203. //
  1204. // ERROR_SUCCESS
  1205. // the sdp element was parsed correctly
  1206. //
  1207. function BluetoothSdpGetElementData(
  1208. pSdpStream: PBYTE;
  1209. cbSdpStreamLength: ULONG;
  1210. pData: PSDP_ELEMENT_DATA): DWORD; stdcall;
  1211. {$EXTERNALSYM BluetoothSdpGetElementData}
  1212. type
  1213. HBLUETOOTH_CONTAINER_ELEMENT = THandle;
  1214. {$EXTERNALSYM HBLUETOOTH_CONTAINER_ELEMENT}
  1215. //
  1216. // Description:
  1217. // Iterates over a container stream, returning each elemetn contained with
  1218. // in the container element at the beginning of pContainerStream
  1219. //
  1220. // Parameters:
  1221. // IN pContainerStream
  1222. // pointer to valid SDP stream whose first element is either a sequence
  1223. // or alternative
  1224. //
  1225. // IN cbContainerlength
  1226. // length in bytes of pContainerStream
  1227. //
  1228. // IN OUT pElement
  1229. // Value used to keep track of location within the stream. The first
  1230. // time this function is called for a particular container, *pElement
  1231. // should equal NULL. Upon subsequent calls, the value should be
  1232. // unmodified.
  1233. //
  1234. // OUT pData
  1235. // pointer to be filled in with the data of the SDP element at the
  1236. // current element of pContainerStream
  1237. //
  1238. // Return Values:
  1239. // ERROR_SUCCESS
  1240. // The call succeeded, pData contains the data
  1241. //
  1242. // ERROR_NO_MORE_ITEMS
  1243. // There are no more items in the list, the caller should cease calling
  1244. // BluetoothSdpGetContainerElementData for this container.
  1245. //
  1246. // ERROR_INVALID_PARAMETER
  1247. // A required pointer is NULL or the container is not a valid SDP
  1248. // stream
  1249. //
  1250. // Usage example:
  1251. //
  1252. // HBLUETOOTH_CONTAINER_ELEMENT element;
  1253. // SDP_ELEMENT_DATA data;
  1254. // ULONG result;
  1255. //
  1256. // element = NULL;
  1257. //
  1258. // while (TRUE) {
  1259. // result = BluetoothSdpGetContainerElementData(
  1260. // pContainer, ulContainerLength, &element, &data);
  1261. //
  1262. // if (result == ERROR_NO_MORE_ITEMS) {
  1263. // // We are done
  1264. // break;
  1265. // }
  1266. // else if (result != ERROR_SUCCESS) {
  1267. // // error
  1268. // }
  1269. //
  1270. // // do something with data ...
  1271. // }
  1272. //
  1273. //
  1274. function BluetoothSdpGetContainerElementData(
  1275. pContainerStream: PBYTE;
  1276. cbContainerLength: ULONG;
  1277. var pElement: HBLUETOOTH_CONTAINER_ELEMENT;
  1278. pData: PSDP_ELEMENT_DATA): DWORD; stdcall;
  1279. {$EXTERNALSYM BluetoothSdpGetContainerElementData}
  1280. //
  1281. // Description:
  1282. // Retrieves the attribute value for the given attribute ID. pRecordStream
  1283. // must be an SDP stream that is formatted as an SDP record, a SEQUENCE
  1284. // containing UINT16 + element pairs.
  1285. //
  1286. // Parameters:
  1287. // IN pRecordStream
  1288. // pointer to a valid SDP stream which is formatted as a singl SDP
  1289. // record
  1290. //
  1291. // IN cbRecordlnegh
  1292. // length of pRecordStream in bytes
  1293. //
  1294. // IN usAttributeId
  1295. // the attribute ID to search for. see bthdef.h for SDP_ATTRIB_Xxx
  1296. // values.
  1297. //
  1298. // OUT pAttributeData
  1299. // pointer that will contain the attribute ID's value
  1300. //
  1301. // Return Values:
  1302. // ERRROR_SUCCESS
  1303. // Call succeeded, pAttributeData contains the attribute value
  1304. //
  1305. // ERROR_INVALID_PARAMETER
  1306. // One of the required pointers was NULL, pRecordStream was not a valid
  1307. // SDP stream, or pRecordStream was not a properly formatted SDP record
  1308. //
  1309. // ERROR_FILE_NOT_FOUND
  1310. // usAttributeId was not found in the record
  1311. //
  1312. // Usage:
  1313. //
  1314. // ULONG result;
  1315. // SDP_DATA_ELEMENT data;
  1316. //
  1317. // result = BluetoothSdpGetAttributeValue(
  1318. // pRecordStream, cbRecordLength, SDP_ATTRIB_RECORD_HANDLE, &data);
  1319. // if (result == ERROR_SUCCESS) {
  1320. // printf("record handle is 0x%x\n", data.data.uint32);
  1321. // }
  1322. //
  1323. function BluetoothSdpGetAttributeValue(
  1324. pRecordStream: PBYTE;
  1325. cbRecordLength: ULONG;
  1326. usAttributeId: Word;
  1327. pAttributeData: PSDP_ELEMENT_DATA): DWORD; stdcall;
  1328. {$EXTERNALSYM BluetoothSdpGetAttributeValue}
  1329. //
  1330. // These three fields correspond one to one with the triplets defined in the
  1331. // SDP specification for the language base attribute ID list.
  1332. //
  1333. type
  1334. _SDP_STRING_TYPE_DATA = record
  1335. //
  1336. // How the string is encoded according to ISO 639:1988 (E/F): "Code
  1337. // for the representation of names of languages".
  1338. //
  1339. encoding: Word;
  1340. //
  1341. // MIBE number from IANA database
  1342. //
  1343. mibeNum: Word;
  1344. //
  1345. // The base attribute where the string is to be found in the record
  1346. //
  1347. attributeId: Word;
  1348. end;
  1349. {$EXTERNALSYM _SDP_STRING_TYPE_DATA}
  1350. SDP_STRING_TYPE_DATA = _SDP_STRING_TYPE_DATA;
  1351. {$EXTERNALSYM SDP_STRING_TYPE_DATA}
  1352. PSDP_STRING_TYPE_DATA = ^SDP_STRING_TYPE_DATA;
  1353. {$EXTERNALSYM PSDP_STRING_TYPE_DATA}
  1354. TSdpStringTypeData = SDP_STRING_TYPE_DATA;
  1355. PSdpStringTypeData = PSDP_STRING_TYPE_DATA;
  1356. //
  1357. // Description:
  1358. // Converts a raw string embedded in the SDP record into a UNICODE string
  1359. //
  1360. // Parameters:
  1361. // IN pRecordStream
  1362. // a valid SDP stream which is formatted as an SDP record
  1363. //
  1364. // IN cbRecordLength
  1365. // length of pRecordStream in bytes
  1366. //
  1367. // IN pStringData
  1368. // if NULL, then the calling thread's locale will be used to search
  1369. // for a matching string in the SDP record. If not NUL, the mibeNum
  1370. // and attributeId will be used to find the string to convert.
  1371. //
  1372. // IN usStringOffset
  1373. // the SDP string type offset to convert. usStringOffset is added to
  1374. // the base attribute id of the string. SDP specification defined
  1375. // offsets are: STRING_NAME_OFFSET, STRING_DESCRIPTION_OFFSET, and
  1376. // STRING_PROVIDER_NAME_OFFSET (found in bthdef.h).
  1377. //
  1378. // OUT pszString
  1379. // if NULL, pcchStringLength will be filled in with the required number
  1380. // of characters (not bytes) to retrieve the converted string.
  1381. //
  1382. // IN OUT pcchStringLength
  1383. // Upon input, if pszString is not NULL, will contain the length of
  1384. // pszString in characters. Upon output, it will contain either the
  1385. // number of required characters including NULL if an error is returned
  1386. // or the number of characters written to pszString (including NULL).
  1387. //
  1388. // Return Values:
  1389. // ERROR_SUCCES
  1390. // Call was successful and pszString contains the converted string
  1391. //
  1392. // ERROR_MORE_DATA
  1393. // pszString was NULL or too small to contain the converted string,
  1394. // pccxhStringLength contains the required length in characters
  1395. //
  1396. // ERROR_INVALID_DATA
  1397. // Could not perform the conversion
  1398. //
  1399. // ERROR_NO_SYSTEM_RESOURCES
  1400. // Could not allocate memory internally to perform the conversion
  1401. //
  1402. // ERROR_INVALID_PARAMETER
  1403. // One of the rquired pointers was NULL, pRecordStream was not a valid
  1404. // SDP stream, pRecordStream was not a properly formatted record, or
  1405. // the desired attribute + offset was not a string.
  1406. //
  1407. // Other HRESULTs returned by COM
  1408. //
  1409. function BluetoothSdpGetString(
  1410. pRecordStream: PBYTE;
  1411. cbRecordLength: ULONG;
  1412. pStringData: PSDP_STRING_TYPE_DATA;
  1413. usStringOffset: Word;
  1414. pszString: PWideChar;
  1415. pcchStringLength: PULONG): DWORD; stdcall;
  1416. {$EXTERNALSYM BluetoothSdpGetString}
  1417. // ***************************************************************************
  1418. //
  1419. // Raw Attribute Enumeration
  1420. //
  1421. // ***************************************************************************
  1422. type
  1423. PFN_BLUETOOTH_ENUM_ATTRIBUTES_CALLBACK = function(
  1424. uAttribId: ULONG;
  1425. pValueStream: PBYTE;
  1426. cbStreamSize: ULONG;
  1427. pvParam: Pointer): BOOL; stdcall;
  1428. {$EXTERNALSYM PFN_BLUETOOTH_ENUM_ATTRIBUTES_CALLBACK}
  1429. //
  1430. // Description:
  1431. // Enumerates through the SDP record stream calling the Callback function
  1432. // for each attribute in the record. If the Callback function returns
  1433. // FALSE, the enumeration is stopped.
  1434. //
  1435. // Return Values:
  1436. // TRUE
  1437. // Success! Something was enumerated.
  1438. //
  1439. // FALSE
  1440. // Failure. GetLastError() could be one of the following:
  1441. //
  1442. // ERROR_INVALID_PARAMETER
  1443. // pSDPStream or pfnCallback is NULL.
  1444. //
  1445. // ERROR_INVALID_DATA
  1446. // The SDP stream is corrupt.
  1447. //
  1448. // other Win32 errors.
  1449. //
  1450. function BluetoothSdpEnumAttributes(
  1451. pSDPStream: PBYTE;
  1452. cbStreamSize: ULONG;
  1453. pfnCallback: PFN_BLUETOOTH_ENUM_ATTRIBUTES_CALLBACK;
  1454. pvParam: Pointer): BOOL; stdcall;
  1455. {$EXTERNALSYM BluetoothSdpEnumAttributes}
  1456. // (rom) MACRO
  1457. function BluetoothEnumAttributes(
  1458. pSDPStream: PBYTE;
  1459. cbStreamSize: ULONG;
  1460. pfnCallback: PFN_BLUETOOTH_ENUM_ATTRIBUTES_CALLBACK;
  1461. pvParam: Pointer): BOOL;
  1462. {$EXTERNALSYM BluetoothEnumAttributes}
  1463. implementation
  1464. const
  1465. btapi = 'irprops.cpl';
  1466. // (rom) MACRO implementation
  1467. function BluetoothEnumAttributes(pSDPStream: PBYTE; cbStreamSize: ULONG;
  1468. pfnCallback: PFN_BLUETOOTH_ENUM_ATTRIBUTES_CALLBACK; pvParam: Pointer): BOOL;
  1469. begin
  1470. Result := BluetoothSdpEnumAttributes(pSDPStream, cbStreamSize, pfnCallback, pvParam);
  1471. end;
  1472. {$IFDEF DYNAMIC_LINK}
  1473. var
  1474. _BluetoothFindFirstRadio: Pointer;
  1475. function BluetoothFindFirstRadio;
  1476. begin
  1477. GetProcedureAddress(_BluetoothFindFirstRadio, btapi, 'BluetoothFindFirstRadio');
  1478. asm
  1479. MOV ESP, EBP
  1480. POP EBP
  1481. JMP [_BluetoothFindFirstRadio]
  1482. end;
  1483. end;
  1484. var
  1485. _BluetoothFindNextRadio: Pointer;
  1486. function BluetoothFindNextRadio;
  1487. begin
  1488. GetProcedureAddress(_BluetoothFindNextRadio, btapi, 'BluetoothFindNextRadio');
  1489. asm
  1490. MOV ESP, EBP
  1491. POP EBP
  1492. JMP [_BluetoothFindNextRadio]
  1493. end;
  1494. end;
  1495. var
  1496. _BluetoothFindRadioClose: Pointer;
  1497. function BluetoothFindRadioClose;
  1498. begin
  1499. GetProcedureAddress(_BluetoothFindRadioClose, btapi, 'BluetoothFindRadioClose');
  1500. asm
  1501. MOV ESP, EBP
  1502. POP EBP
  1503. JMP [_BluetoothFindRadioClose]
  1504. end;
  1505. end;
  1506. var
  1507. _BluetoothGetRadioInfo: Pointer;
  1508. function BluetoothGetRadioInfo;
  1509. begin
  1510. GetProcedureAddress(_BluetoothGetRadioInfo, btapi, 'BluetoothGetRadioInfo');
  1511. asm
  1512. MOV ESP, EBP
  1513. POP EBP
  1514. JMP [_BluetoothGetRadioInfo]
  1515. end;
  1516. end;
  1517. var
  1518. _BluetoothFindFirstDevice: Pointer;
  1519. function BluetoothFindFirstDevice;
  1520. begin
  1521. GetProcedureAddress(_BluetoothFindFirstDevice, btapi, 'BluetoothFindFirstDevice');
  1522. asm
  1523. MOV ESP, EBP
  1524. POP EBP
  1525. JMP [_BluetoothFindFirstDevice]
  1526. end;
  1527. end;
  1528. var
  1529. _BluetoothFindNextDevice: Pointer;
  1530. function BluetoothFindNextDevice;
  1531. begin
  1532. GetProcedureAddress(_BluetoothFindNextDevice, btapi, 'BluetoothFindNextDevice');
  1533. asm
  1534. MOV ESP, EBP
  1535. POP EBP
  1536. JMP [_BluetoothFindNextDevice]
  1537. end;
  1538. end;
  1539. var
  1540. _BluetoothFindDeviceClose: Pointer;
  1541. function BluetoothFindDeviceClose;
  1542. begin
  1543. GetProcedureAddress(_BluetoothFindDeviceClose, btapi, 'BluetoothFindDeviceClose');
  1544. asm
  1545. MOV ESP, EBP
  1546. POP EBP
  1547. JMP [_BluetoothFindDeviceClose]
  1548. end;
  1549. end;
  1550. var
  1551. _BluetoothGetDeviceInfo: Pointer;
  1552. function BluetoothGetDeviceInfo;
  1553. begin
  1554. GetProcedureAddress(_BluetoothGetDeviceInfo, btapi, 'BluetoothGetDeviceInfo');
  1555. asm
  1556. MOV ESP, EBP
  1557. POP EBP
  1558. JMP [_BluetoothGetDeviceInfo]
  1559. end;
  1560. end;
  1561. var
  1562. _BluetoothUpdateDeviceRecord: Pointer;
  1563. function BluetoothUpdateDeviceRecord;
  1564. begin
  1565. GetProcedureAddress(_BluetoothUpdateDeviceRecord, btapi, 'BluetoothUpdateDeviceRecord');
  1566. asm
  1567. MOV ESP, EBP
  1568. POP EBP
  1569. JMP [_BluetoothUpdateDeviceRecord]
  1570. end;
  1571. end;
  1572. var
  1573. _BluetoothRemoveDevice: Pointer;
  1574. function BluetoothRemoveDevice;
  1575. begin
  1576. GetProcedureAddress(_BluetoothRemoveDevice, btapi, 'BluetoothRemoveDevice');
  1577. asm
  1578. MOV ESP, EBP
  1579. POP EBP
  1580. JMP [_BluetoothRemoveDevice]
  1581. end;
  1582. end;
  1583. var
  1584. _BluetoothSelectDevices: Pointer;
  1585. function BluetoothSelectDevices;
  1586. begin
  1587. GetProcedureAddress(_BluetoothSelectDevices, btapi, 'BluetoothSelectDevices');
  1588. asm
  1589. MOV ESP, EBP
  1590. POP EBP
  1591. JMP [_BluetoothSelectDevices]
  1592. end;
  1593. end;
  1594. var
  1595. _BluetoothSelectDevicesFree: Pointer;
  1596. function BluetoothSelectDevicesFree;
  1597. begin
  1598. GetProcedureAddress(_BluetoothSelectDevicesFree, btapi, 'BluetoothSelectDevicesFree');
  1599. asm
  1600. MOV ESP, EBP
  1601. POP EBP
  1602. JMP [_BluetoothSelectDevicesFree]
  1603. end;
  1604. end;
  1605. var
  1606. _BluetoothDisplayDeviceProperties: Pointer;
  1607. function BluetoothDisplayDeviceProperties;
  1608. begin
  1609. GetProcedureAddress(_BluetoothDisplayDeviceProperties, btapi, 'BluetoothDisplayDeviceProperties');
  1610. asm
  1611. MOV ESP, EBP
  1612. POP EBP
  1613. JMP [_BluetoothDisplayDeviceProperties]
  1614. end;
  1615. end;
  1616. var
  1617. _BluetoothAuthenticateDevice: Pointer;
  1618. function BluetoothAuthenticateDevice;
  1619. begin
  1620. GetProcedureAddress(_BluetoothAuthenticateDevice, btapi, 'BluetoothAuthenticateDevice');
  1621. asm
  1622. MOV ESP, EBP
  1623. POP EBP
  1624. JMP [_BluetoothAuthenticateDevice]
  1625. end;
  1626. end;
  1627. var
  1628. _BluetoothAuthenticateMultipleDevices: Pointer;
  1629. function BluetoothAuthenticateMultipleDevices;
  1630. begin
  1631. GetProcedureAddress(_BluetoothAuthenticateMultipleDevices, btapi, 'BluetoothAuthenticateMultipleDevices');
  1632. asm
  1633. MOV ESP, EBP
  1634. POP EBP
  1635. JMP [_BluetoothAuthenticateMultipleDevices]
  1636. end;
  1637. end;
  1638. var
  1639. _BluetoothSetServiceState: Pointer;
  1640. function BluetoothSetServiceState;
  1641. begin
  1642. GetProcedureAddress(_BluetoothSetServiceState, btapi, 'BluetoothSetServiceState');
  1643. asm
  1644. MOV ESP, EBP
  1645. POP EBP
  1646. JMP [_BluetoothSetServiceState]
  1647. end;
  1648. end;
  1649. var
  1650. _BluetoothEnumerateInstalledServices: Pointer;
  1651. function BluetoothEnumerateInstalledServices;
  1652. begin
  1653. GetProcedureAddress(_BluetoothEnumerateInstalledServices, btapi, 'BluetoothEnumerateInstalledServices');
  1654. asm
  1655. MOV ESP, EBP
  1656. POP EBP
  1657. JMP [_BluetoothEnumerateInstalledServices]
  1658. end;
  1659. end;
  1660. var
  1661. _BluetoothEnableDiscovery: Pointer;
  1662. function BluetoothEnableDiscovery;
  1663. begin
  1664. GetProcedureAddress(_BluetoothEnableDiscovery, btapi, 'BluetoothEnableDiscovery');
  1665. asm
  1666. MOV ESP, EBP
  1667. POP EBP
  1668. JMP [_BluetoothEnableDiscovery]
  1669. end;
  1670. end;
  1671. var
  1672. _BluetoothIsDiscoverable: Pointer;
  1673. function BluetoothIsDiscoverable;
  1674. begin
  1675. GetProcedureAddress(_BluetoothIsDiscoverable, btapi, 'BluetoothIsDiscoverable');
  1676. asm
  1677. MOV ESP, EBP
  1678. POP EBP
  1679. JMP [_BluetoothIsDiscoverable]
  1680. end;
  1681. end;
  1682. var
  1683. _BluetoothEnableIncomingConnections: Pointer;
  1684. function BluetoothEnableIncomingConnections;
  1685. begin
  1686. GetProcedureAddress(_BluetoothEnableIncomingConnections, btapi, 'BluetoothEnableIncomingConnections');
  1687. asm
  1688. MOV ESP, EBP
  1689. POP EBP
  1690. JMP [_BluetoothEnableIncomingConnections]
  1691. end;
  1692. end;
  1693. var
  1694. _BluetoothIsConnectable: Pointer;
  1695. function BluetoothIsConnectable;
  1696. begin
  1697. GetProcedureAddress(_BluetoothIsConnectable, btapi, 'BluetoothIsConnectable');
  1698. asm
  1699. MOV ESP, EBP
  1700. POP EBP
  1701. JMP [_BluetoothIsConnectable]
  1702. end;
  1703. end;
  1704. var
  1705. _BluetoothRegisterForAuthentication: Pointer;
  1706. function BluetoothRegisterForAuthentication;
  1707. begin
  1708. GetProcedureAddress(_BluetoothRegisterForAuthentication, btapi, 'BluetoothRegisterForAuthentication');
  1709. asm
  1710. MOV ESP, EBP
  1711. POP EBP
  1712. JMP [_BluetoothRegisterForAuthentication]
  1713. end;
  1714. end;
  1715. var
  1716. _BluetoothUnregisterAuthentication: Pointer;
  1717. function BluetoothUnregisterAuthentication;
  1718. begin
  1719. GetProcedureAddress(_BluetoothUnregisterAuthentication, btapi, 'BluetoothUnregisterAuthentication');
  1720. asm
  1721. MOV ESP, EBP
  1722. POP EBP
  1723. JMP [_BluetoothUnregisterAuthentication]
  1724. end;
  1725. end;
  1726. var
  1727. _BluetoothSendAuthenticationResponse: Pointer;
  1728. function BluetoothSendAuthenticationResponse;
  1729. begin
  1730. GetProcedureAddress(_BluetoothSendAuthenticationResponse, btapi, 'BluetoothSendAuthenticationResponse');
  1731. asm
  1732. MOV ESP, EBP
  1733. POP EBP
  1734. JMP [_BluetoothSendAuthenticationResponse]
  1735. end;
  1736. end;
  1737. var
  1738. _BluetoothSdpGetElementData: Pointer;
  1739. function BluetoothSdpGetElementData;
  1740. begin
  1741. GetProcedureAddress(_BluetoothSdpGetElementData, btapi, 'BluetoothSdpGetElementData');
  1742. asm
  1743. MOV ESP, EBP
  1744. POP EBP
  1745. JMP [_BluetoothSdpGetElementData]
  1746. end;
  1747. end;
  1748. var
  1749. _BluetoothSdpGetContainerElementData: Pointer;
  1750. function BluetoothSdpGetContainerElementData;
  1751. begin
  1752. GetProcedureAddress(_BluetoothSdpGetContainerElementData, btapi, 'BluetoothSdpGetContainerElementData');
  1753. asm
  1754. MOV ESP, EBP
  1755. POP EBP
  1756. JMP [_BluetoothSdpGetContainerElementData]
  1757. end;
  1758. end;
  1759. var
  1760. _BluetoothSdpGetAttributeValue: Pointer;
  1761. function BluetoothSdpGetAttributeValue;
  1762. begin
  1763. GetProcedureAddress(_BluetoothSdpGetAttributeValue, btapi, 'BluetoothSdpGetAttributeValue');
  1764. asm
  1765. MOV ESP, EBP
  1766. POP EBP
  1767. JMP [_BluetoothSdpGetAttributeValue]
  1768. end;
  1769. end;
  1770. var
  1771. _BluetoothSdpGetString: Pointer;
  1772. function BluetoothSdpGetString;
  1773. begin
  1774. GetProcedureAddress(_BluetoothSdpGetString, btapi, 'BluetoothSdpGetString');
  1775. asm
  1776. MOV ESP, EBP
  1777. POP EBP
  1778. JMP [_BluetoothSdpGetString]
  1779. end;
  1780. end;
  1781. var
  1782. _BluetoothSdpEnumAttributes: Pointer;
  1783. function BluetoothSdpEnumAttributes;
  1784. begin
  1785. GetProcedureAddress(_BluetoothSdpEnumAttributes, btapi, 'BluetoothSdpEnumAttributes');
  1786. asm
  1787. MOV ESP, EBP
  1788. POP EBP
  1789. JMP [_BluetoothSdpEnumAttributes]
  1790. end;
  1791. end;
  1792. {$ELSE}
  1793. function BluetoothFindFirstRadio; external btapi name 'BluetoothFindFirstRadio';
  1794. function BluetoothFindNextRadio; external btapi name 'BluetoothFindNextRadio';
  1795. function BluetoothFindRadioClose; external btapi name 'BluetoothFindRadioClose';
  1796. function BluetoothGetRadioInfo; external btapi name 'BluetoothGetRadioInfo';
  1797. function BluetoothFindFirstDevice; external btapi name 'BluetoothFindFirstDevice';
  1798. function BluetoothFindNextDevice; external btapi name 'BluetoothFindNextDevice';
  1799. function BluetoothFindDeviceClose; external btapi name 'BluetoothFindDeviceClose';
  1800. function BluetoothGetDeviceInfo; external btapi name 'BluetoothGetDeviceInfo';
  1801. function BluetoothUpdateDeviceRecord; external btapi name 'BluetoothUpdateDeviceRecord';
  1802. function BluetoothRemoveDevice; external btapi name 'BluetoothRemoveDevice';
  1803. function BluetoothSelectDevices; external btapi name 'BluetoothSelectDevices';
  1804. function BluetoothSelectDevicesFree; external btapi name 'BluetoothSelectDevicesFree';
  1805. function BluetoothDisplayDeviceProperties; external btapi name 'BluetoothDisplayDeviceProperties';
  1806. function BluetoothAuthenticateDevice; external btapi name 'BluetoothAuthenticateDevice';
  1807. function BluetoothAuthenticateMultipleDevices; external btapi name 'BluetoothAuthenticateMultipleDevices';
  1808. function BluetoothSetServiceState; external btapi name 'BluetoothSetServiceState';
  1809. function BluetoothEnumerateInstalledServices; external btapi name 'BluetoothEnumerateInstalledServices';
  1810. function BluetoothEnableDiscovery; external btapi name 'BluetoothEnableDiscovery';
  1811. function BluetoothIsDiscoverable; external btapi name 'BluetoothIsDiscoverable';
  1812. function BluetoothEnableIncomingConnections; external btapi name 'BluetoothEnableIncomingConnections';
  1813. function BluetoothIsConnectable; external btapi name 'BluetoothIsConnectable';
  1814. function BluetoothRegisterForAuthentication; external btapi name 'BluetoothRegisterForAuthentication';
  1815. function BluetoothUnregisterAuthentication; external btapi name 'BluetoothUnregisterAuthentication';
  1816. function BluetoothSendAuthenticationResponse; external btapi name 'BluetoothSendAuthenticationResponse';
  1817. function BluetoothSdpGetElementData; external btapi name 'BluetoothSdpGetElementData';
  1818. function BluetoothSdpGetContainerElementData; external btapi name 'BluetoothSdpGetContainerElementData';
  1819. function BluetoothSdpGetAttributeValue; external btapi name 'BluetoothSdpGetAttributeValue';
  1820. function BluetoothSdpGetString; external btapi name 'BluetoothSdpGetString';
  1821. function BluetoothSdpEnumAttributes; external btapi name 'BluetoothSdpEnumAttributes';
  1822. {$ENDIF DYNAMIC_LINK}
  1823. end.