jwabluetoothapis.pas 65 KB

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