00001 // 00002 // Copyright 2002 - 2004, Microsoft Corporation 00003 // 00005 00006 #pragma once 00007 00008 00009 #define BLUETOOTH_MAX_NAME_SIZE (248) 00010 #define BLUETOOTH_MAX_PASSKEY_SIZE (16) 00011 #define BLUETOOTH_MAX_PASSKEY_BUFFER_SIZE (BLUETOOTH_MAX_PASSKEY_SIZE + 1) 00012 #define BLUETOOTH_MAX_SERVICE_NAME_SIZE (256) 00013 #define BLUETOOTH_DEVICE_NAME_SIZE (256) 00014 00015 00016 #ifdef __cplusplus 00017 extern "C" { 00018 #endif 00019 00020 #if (NTDDI_VERSION >= NTDDI_WINXPSP2) 00021 00022 // *************************************************************************** 00023 // 00024 // Bluetooth Address 00025 // 00026 // *************************************************************************** 00027 00028 typedef ULONGLONG BTH_ADDR; 00029 00030 typedef struct _BLUETOOTH_ADDRESS { 00031 union { 00032 BTH_ADDR ullLong; // easier to compare again BLUETOOTH_NULL_ADDRESS 00033 BYTE rgBytes[ 6 ]; // easier to format when broken out 00034 }; 00035 00036 } BLUETOOTH_ADDRESS_STRUCT; 00037 00038 #define BLUETOOTH_ADDRESS BLUETOOTH_ADDRESS_STRUCT 00039 00040 #define BLUETOOTH_NULL_ADDRESS ( (ULONGLONG) 0x0 ) 00041 00042 00043 00044 typedef struct _BLUETOOTH_LOCAL_SERVICE_INFO { 00045 BOOL Enabled; // If TRUE, the enable the services 00046 00047 BLUETOOTH_ADDRESS btAddr; // If service is to be advertised for a particular remote device 00048 00049 WCHAR szName[ BLUETOOTH_MAX_SERVICE_NAME_SIZE ]; // SDP Service Name to be advertised. 00050 WCHAR szDeviceString[ BLUETOOTH_DEVICE_NAME_SIZE ]; // Local device name (if any) like COM4 or LPT1 00051 00052 } BLUETOOTH_LOCAL_SERVICE_INFO_STRUCT; 00053 00054 #define BLUETOOTH_LOCAL_SERVICE_INFO BLUETOOTH_LOCAL_SERVICE_INFO_STRUCT 00055 00056 typedef BLUETOOTH_LOCAL_SERVICE_INFO * PBLUETOOTH_LOCAL_SERVICE_INFO; 00057 00058 00059 00060 00061 00062 // *************************************************************************** 00063 // 00064 // Radio Enumeration 00065 // 00066 // Description: 00067 // This group of APIs enumerates the installed Bluetooth radios. 00068 // 00069 // Sample Usage: 00070 // HANDLE hRadio; 00071 // BLUETOOTH_FIND_RADIO_PARAMS btfrp = { sizeof(btfrp) }; 00072 // 00073 // HBLUETOOTH_RADIO_FIND hFind = BluetoothFindFirstRadio( &btfrp, &hRadio ); 00074 // if ( NULL != hFind ) 00075 // { 00076 // do 00077 // { 00078 // // 00079 // // TODO: Do something with the radio handle. 00080 // // 00081 // 00082 // CloseHandle( hRadio ); 00083 // 00084 // } while( BluetoothFindNextRadio( hFind, &hRadio ) ); 00085 // 00086 // BluetoothFindRadioClose( hFind ); 00087 // } 00088 // 00089 // *************************************************************************** 00090 00091 typedef struct _BLUETOOTH_FIND_RADIO_PARAMS { 00092 DWORD dwSize; // IN sizeof this structure 00093 00094 } BLUETOOTH_FIND_RADIO_PARAMS; 00095 00096 typedef HANDLE HBLUETOOTH_RADIO_FIND; 00097 00098 // 00099 // Description: 00100 // Begins the enumeration of local Bluetooth radios. 00101 // 00102 // Parameters: 00103 // pbtfrp 00104 // A pointer to a BLUETOOTH_FIND_RADIO_PARAMS structure. The dwSize 00105 // member of this structure must match the sizeof the of the structure. 00106 // 00107 // phRadio 00108 // A pointer where the first radio HANDLE enumerated will be returned. 00109 // 00110 // Return Values: 00111 // NULL 00112 // Error opening radios or no devices found. Use GetLastError() for 00113 // more info. 00114 // 00115 // ERROR_INVALID_PARAMETER 00116 // pbtfrp parameter is NULL. 00117 // 00118 // ERROR_REVISION_MISMATCH 00119 // The pbtfrp structure is not the right length. 00120 // 00121 // ERROR_OUTOFMEMORY 00122 // Out of memory. 00123 // 00124 // other Win32 errors. 00125 // 00126 // any other 00127 // Success. The return handle is valid and phRadio points to a valid handle. 00128 // 00129 HBLUETOOTH_RADIO_FIND 00130 WINAPI 00131 BluetoothFindFirstRadio( 00132 const BLUETOOTH_FIND_RADIO_PARAMS * pbtfrp, 00133 __out HANDLE * phRadio 00134 ); 00135 00136 // 00137 // Description: 00138 // Finds the next installed Bluetooth radio. 00139 // 00140 // Parameters: 00141 // hFind 00142 // The handle returned by BluetoothFindFirstRadio(). 00143 // 00144 // phRadio 00145 // A pointer where the next radio HANDLE enumerated will be returned. 00146 // 00147 // Return Values: 00148 // TRUE 00149 // Next device succesfully found. pHandleOut points to valid handle. 00150 // 00151 // FALSE 00152 // No device found. pHandleOut points to an invalid handle. Call 00153 // GetLastError() for more details. 00154 // 00155 // ERROR_INVALID_HANDLE 00156 // The handle is NULL. 00157 // 00158 // ERROR_NO_MORE_ITEMS 00159 // No more radios found. 00160 // 00161 // ERROR_OUTOFMEMORY 00162 // Out of memory. 00163 // 00164 // other Win32 errors 00165 // 00166 BOOL 00167 WINAPI 00168 BluetoothFindNextRadio( 00169 __in HBLUETOOTH_RADIO_FIND hFind, 00170 __out HANDLE * phRadio 00171 ); 00172 00173 // 00174 // Description: 00175 // Closes the enumeration handle. 00176 // 00177 // Parameters 00178 // hFind 00179 // The handle returned by BluetoothFindFirstRadio(). 00180 // 00181 // Return Values: 00182 // TRUE 00183 // Handle succesfully closed. 00184 // 00185 // FALSE 00186 // Failure. Check GetLastError() for details. 00187 // 00188 // ERROR_INVALID_HANDLE 00189 // The handle is NULL. 00190 // 00191 BOOL 00192 WINAPI 00193 BluetoothFindRadioClose( 00194 __in HBLUETOOTH_RADIO_FIND hFind 00195 ); 00196 00197 // *************************************************************************** 00198 // 00199 // Radio Information 00200 // 00201 // *************************************************************************** 00202 00203 typedef struct _BLUETOOTH_RADIO_INFO { 00204 DWORD dwSize; // Size, in bytes, of this entire data structure 00205 00206 BLUETOOTH_ADDRESS address; // Address of the local radio 00207 00208 WCHAR szName[ BLUETOOTH_MAX_NAME_SIZE ]; // Name of the local radio 00209 00210 ULONG ulClassofDevice; // Class of device for the local radio 00211 00212 USHORT lmpSubversion; // lmpSubversion, manufacturer specifc. 00213 USHORT manufacturer; // Manufacturer of the radio, BTH_MFG_Xxx value. For the most up to date 00214 // list, goto the Bluetooth specification website and get the Bluetooth 00215 // assigned numbers document. 00216 } BLUETOOTH_RADIO_INFO, *PBLUETOOTH_RADIO_INFO; 00217 00218 // 00219 // Description: 00220 // Retrieves the information about the radio represented by the handle. 00221 // 00222 // Parameters: 00223 // hRadio 00224 // Handle to a local radio retrieved through BluetoothFindFirstRadio() 00225 // et al or SetupDiEnumerateDeviceInterfaces() 00226 // 00227 // pRadioInfo 00228 // Radio information to be filled in. The dwSize member must match the 00229 // size of the structure. 00230 // 00231 // Return Values: 00232 // ERROR_SUCCESS 00233 // The information was retrieved successfully. 00234 // 00235 // ERROR_INVALID_PARAMETER 00236 // pRadioInfo or hRadio is NULL. 00237 // 00238 // ERROR_REVISION_MISMATCH 00239 // pRadioInfo->dwSize is invalid. 00240 // 00241 // other Win32 error codes. 00242 // 00243 DWORD 00244 WINAPI 00245 BluetoothGetRadioInfo( 00246 __in HANDLE hRadio, 00247 __inout PBLUETOOTH_RADIO_INFO pRadioInfo 00248 ); 00249 00250 // *************************************************************************** 00251 // 00252 // Device Information Stuctures 00253 // 00254 // *************************************************************************** 00255 00256 typedef __struct_bcount(dwSize) struct _BLUETOOTH_DEVICE_INFO { 00257 DWORD dwSize; // size, in bytes, of this structure - must be the sizeof(BLUETOOTH_DEVICE_INFO) 00258 00259 BLUETOOTH_ADDRESS Address; // Bluetooth address 00260 00261 ULONG ulClassofDevice; // Bluetooth "Class of Device" 00262 00263 BOOL fConnected; // Device connected/in use 00264 BOOL fRemembered; // Device remembered 00265 BOOL fAuthenticated; // Device authenticated/paired/bonded 00266 00267 SYSTEMTIME stLastSeen; // Last time the device was seen 00268 SYSTEMTIME stLastUsed; // Last time the device was used for other than RNR, inquiry, or SDP 00269 00270 WCHAR szName[ BLUETOOTH_MAX_NAME_SIZE ]; // Name of the device 00271 00272 } BLUETOOTH_DEVICE_INFO_STRUCT; 00273 00274 #define BLUETOOTH_DEVICE_INFO BLUETOOTH_DEVICE_INFO_STRUCT 00275 00276 typedef BLUETOOTH_DEVICE_INFO * PBLUETOOTH_DEVICE_INFO; 00277 00278 // *************************************************************************** 00279 // 00280 // Device Enumeration 00281 // 00282 // Description: 00283 // Enumerates the Bluetooth devices. The types of returned device depends 00284 // on the flags set in the BLUETOOTH_DEVICE_SEARCH_PARAMS (see structure 00285 // definition for details). 00286 // 00287 // Sample Usage: 00288 // HBLUETOOTH_DEVICE_FIND hFind; 00289 // BLUETOOTH_DEVICE_SEARCH_PARAMS btsp = { sizeof(btsp) }; 00290 // BLUETOOTH_DEVICE_INFO btdi = { sizeof(btdi) }; 00291 // 00292 // btsp.fReturnAuthenticated = TRUE; 00293 // btsp.fReturnRemembered = TRUE; 00294 // 00295 // hFind = BluetoothFindFirstDevice( &btsp, &btdi ); 00296 // if ( NULL != hFind ) 00297 // { 00298 // do 00299 // { 00300 // // 00301 // // TODO: Do something useful with the device info. 00302 // // 00303 // 00304 // } while( BluetoothFindNextDevice( hFind, &btdi ) ); 00305 // 00306 // BluetoothFindDeviceClose( hFind ); 00307 // } 00308 // 00309 // *************************************************************************** 00310 00311 typedef struct _BLUETOOTH_DEVICE_SEARCH_PARAMS { 00312 DWORD dwSize; // IN sizeof this structure 00313 00314 BOOL fReturnAuthenticated; // IN return authenticated devices 00315 BOOL fReturnRemembered; // IN return remembered devices 00316 BOOL fReturnUnknown; // IN return unknown devices 00317 BOOL fReturnConnected; // IN return connected devices 00318 00319 BOOL fIssueInquiry; // IN issue a new inquiry 00320 UCHAR cTimeoutMultiplier; // IN timeout for the inquiry 00321 00322 HANDLE hRadio; // IN handle to radio to enumerate - NULL == all radios will be searched 00323 00324 } BLUETOOTH_DEVICE_SEARCH_PARAMS; 00325 00326 typedef HANDLE HBLUETOOTH_DEVICE_FIND; 00327 00328 // 00329 // Description: 00330 // Begins the enumeration of Bluetooth devices. 00331 // 00332 // Parameters: 00333 // pbtsp 00334 // A pointer to a BLUETOOTH_DEVICE_SEARCH_PARAMS structure. This 00335 // structure contains the flags and inputs used to conduct the search. 00336 // See BLUETOOTH_DEVICE_SEARCH_PARAMS for details. 00337 // 00338 // pbtdi 00339 // A pointer to a BLUETOOTH_DEVICE_INFO structure to return information 00340 // about the first Bluetooth device found. Note that the dwSize member 00341 // of the structure must be the sizeof(BLUETOOTH_DEVICE_INFO) before 00342 // calling because the APIs hast to know the size of the buffer being 00343 // past in. The dwSize member must also match the exact 00344 // sizeof(BLUETOOTH_DEVICE_INFO) or the call will fail. 00345 // 00346 // Return Values: 00347 // NULL 00348 // Error opening radios or not devices found. Use GetLastError for more info. 00349 // 00350 // ERROR_INVALID_PARAMETER 00351 // pbtsp parameter or pbtdi parameter is NULL. 00352 // 00353 // ERROR_REVISION_MISMATCH 00354 // The pbtfrp structure is not the right length. 00355 // 00356 // other Win32 errors 00357 // 00358 // any other value 00359 // Success. The return handle is valid and pbtdi points to valid data. 00360 // 00361 HBLUETOOTH_DEVICE_FIND 00362 WINAPI 00363 BluetoothFindFirstDevice( 00364 const BLUETOOTH_DEVICE_SEARCH_PARAMS * pbtsp, 00365 __inout BLUETOOTH_DEVICE_INFO * pbtdi 00366 ); 00367 00368 // 00369 // Description: 00370 // Finds the next Bluetooth device in the enumeration. 00371 // 00372 // Parameters: 00373 // hFind 00374 // The handle returned from BluetoothFindFirstDevice(). 00375 // 00376 // pbtdi 00377 // A pointer to a BLUETOOTH_DEVICE_INFO structure to return information 00378 // about the first Bluetooth device found. Note that the dwSize member 00379 // of the structure must be the sizeof(BLUETOOTH_DEVICE_INFO) before 00380 // calling because the APIs hast to know the size of the buffer being 00381 // past in. The dwSize member must also match the exact 00382 // sizeof(BLUETOOTH_DEVICE_INFO) or the call will fail. 00383 // 00384 // Return Values: 00385 // TRUE 00386 // Next device succesfully found. pHandleOut points to valid handle. 00387 // 00388 // FALSE 00389 // No device found. pHandleOut points to an invalid handle. Call 00390 // GetLastError() for more details. 00391 // 00392 // ERROR_INVALID_HANDLE 00393 // The handle is NULL. 00394 // 00395 // ERROR_NO_MORE_ITEMS 00396 // No more radios found. 00397 // 00398 // ERROR_OUTOFMEMORY 00399 // Out of memory. 00400 // 00401 // other Win32 errors 00402 // 00403 BOOL 00404 WINAPI 00405 BluetoothFindNextDevice( 00406 __in HBLUETOOTH_DEVICE_FIND hFind, 00407 __inout BLUETOOTH_DEVICE_INFO * pbtdi 00408 ); 00409 00410 // 00411 // Description: 00412 // Closes the enumeration handle. 00413 // 00414 // Parameters: 00415 // hFind 00416 // The handle returned from BluetoothFindFirstDevice(). 00417 // 00418 // Return Values: 00419 // TRUE 00420 // Handle succesfully closed. 00421 // 00422 // FALSE 00423 // Failure. Check GetLastError() for details. 00424 // 00425 // ERROR_INVALID_HANDLE 00426 // The handle is NULL. 00427 // 00428 BOOL 00429 WINAPI 00430 BluetoothFindDeviceClose( 00431 __in HBLUETOOTH_DEVICE_FIND hFind 00432 ); 00433 00434 // 00435 // Description: 00436 // Retrieves information about a remote device. 00437 // 00438 // Fill in the dwSize and the Address members of the pbtdi structure 00439 // being passed in. On success, the rest of the members will be filled 00440 // out with the information that the system knows. 00441 // 00442 // Parameters: 00443 // hRadio 00444 // Handle to a local radio retrieved through BluetoothFindFirstRadio() 00445 // et al or SetupDiEnumerateDeviceInterfaces() 00446 // 00447 // pbtdi 00448 // A pointer to a BLUETOOTH_DEVICE_INFO structure to return information 00449 // about the first Bluetooth device found. The dwSize member of the 00450 // structure must be the sizeof the structure in bytes. The Address 00451 // member must be filled out with the Bluetooth address of the remote 00452 // device. 00453 // 00454 // Return Values: 00455 // ERROR_SUCCESS 00456 // Success. Information returned. 00457 // 00458 // ERROR_REVISION_MISMATCH 00459 // The size of the BLUETOOTH_DEVICE_INFO isn't compatible. Check 00460 // the dwSize member of the BLUETOOTH_DEVICE_INFO structure you 00461 // passed in. 00462 // 00463 // ERROR_NOT_FOUND 00464 // The radio is not known by the system or the Address field of 00465 // the BLUETOOTH_DEVICE_INFO structure is all zeros. 00466 // 00467 // ERROR_INVALID_PARAMETER 00468 // pbtdi is NULL. 00469 // 00470 // other error codes 00471 // 00472 DWORD 00473 WINAPI 00474 BluetoothGetDeviceInfo( 00475 __in_opt HANDLE hRadio, 00476 __inout BLUETOOTH_DEVICE_INFO * pbtdi 00477 ); 00478 00479 // 00480 // Description: 00481 // Updates the computer local cache about the device. 00482 // 00483 // Parameters: 00484 // pbtdi 00485 // A pointer to the BLUETOOTH_DEVICE_INFO structure to be updated. 00486 // The following members must be valid: 00487 // dwSize 00488 // Must match the size of the structure. 00489 // Address 00490 // Must be a previously found radio address. 00491 // szName 00492 // New name to be stored. 00493 // 00494 // Return Values: 00495 // ERROR_SUCCESS 00496 // The device information was updated successfully. 00497 // 00498 // ERROR_INVALID_PARAMETER 00499 // pbtdi is NULL. 00500 // 00501 // ERROR_REVISION_MISMATCH 00502 // pbtdi->dwSize is invalid. 00503 // 00504 // other Win32 error codes. 00505 // 00506 DWORD 00507 WINAPI 00508 BluetoothUpdateDeviceRecord( 00509 const BLUETOOTH_DEVICE_INFO * pbtdi 00510 ); 00511 00512 // 00513 // Description: 00514 // Delete the authentication (aka "bond") between the computer and the 00515 // device. Also purges any cached information about the device. 00516 // 00517 // Return Values: 00518 // ERROR_SUCCESS 00519 // The device was removed successfully. 00520 // 00521 // ERROR_NOT_FOUND 00522 // The device was not found. If no Bluetooth radio is installed, 00523 // the devices could not be enumerated or removed. 00524 // 00525 DWORD 00526 WINAPI 00527 BluetoothRemoveDevice( 00528 const BLUETOOTH_ADDRESS * pAddress 00529 ); 00530 00531 // *************************************************************************** 00532 // 00533 // Device Picker Dialog 00534 // 00535 // Description: 00536 // Invokes a common dialog for selecting Bluetooth devices. The list 00537 // of devices displayed to the user is determined by the flags and 00538 // settings the caller specifies in the BLUETOOTH_SELECT_DEVICE_PARAMS 00539 // (see structure definition for more details). 00540 // 00541 // If BluetoothSelectDevices() returns TRUE, the caller must call 00542 // BluetoothSelectDevicesFree() or memory will be leaked within the 00543 // process. 00544 // 00545 // Sample Usage: 00546 // 00547 // BLUETOOTH_SELECT_DEVICE_PARAMS btsdp = { sizeof(btsdp) }; 00548 // 00549 // btsdp.hwndParent = hDlg; 00550 // btsdp.fShowUnknown = TRUE; 00551 // btsdp.fAddNewDeviceWizard = TRUE; 00552 // 00553 // BOOL b = BluetoothSelectDevices( &btsdp ); 00554 // if ( b ) 00555 // { 00556 // BLUETOOTH_DEVICE_INFO * pbtdi = btsdp.pDevices; 00557 // for ( ULONG cDevice = 0; cDevice < btsdp.cNumDevices; cDevice ++ ) 00558 // { 00559 // if ( pbtdi->fAuthenticated || pbtdi->fRemembered ) 00560 // { 00561 // // 00562 // // TODO: Do something usefull with the device info 00563 // // 00564 // } 00565 // 00566 // pbtdi = (BLUETOOTH_DEVICE_INFO *) ((LPBYTE)pbtdi + pbtdi->dwSize); 00567 // } 00568 // 00569 // BluetoothSelectDevicesFree( &btsdp ); 00570 // } 00571 // 00572 // *************************************************************************** 00573 00574 00575 typedef struct _BLUETOOTH_COD_PAIRS { 00576 ULONG ulCODMask; // ClassOfDevice mask to compare 00577 LPCWSTR pcszDescription; // Descriptive string of mask 00578 00579 } BLUETOOTH_COD_PAIRS; 00580 00581 typedef BOOL (WINAPI *PFN_DEVICE_CALLBACK)(LPVOID pvParam, const BLUETOOTH_DEVICE_INFO * pDevice); 00582 00583 typedef struct _BLUETOOTH_SELECT_DEVICE_PARAMS { 00584 DWORD dwSize; // IN sizeof this structure 00585 00586 ULONG cNumOfClasses; // IN Number in prgClassOfDevice - if ZERO search for all devices 00587 BLUETOOTH_COD_PAIRS * prgClassOfDevices; // IN Array of CODs to find. 00588 00589 LPWSTR pszInfo; // IN If not NULL, sets the "information" text 00590 00591 HWND hwndParent; // IN parent window - NULL == no parent 00592 00593 BOOL fForceAuthentication; // IN If TRUE, authenication will be forced before returning 00594 BOOL fShowAuthenticated; // IN If TRUE, authenticated devices will be shown in the picker 00595 BOOL fShowRemembered; // IN If TRUE, remembered devices will be shown in the picker 00596 BOOL fShowUnknown; // IN If TRUE, unknown devices that are not authenticated or "remember" will be shown. 00597 00598 BOOL fAddNewDeviceWizard; // IN If TRUE, invokes the add new device wizard. 00599 BOOL fSkipServicesPage; // IN If TRUE, skips the "Services" page in the wizard. 00600 00601 PFN_DEVICE_CALLBACK pfnDeviceCallback; // IN If non-NULL, a callback that will be called for each device. If the 00602 // the callback returns TRUE, the item will be added. If the callback is 00603 // is FALSE, the item will not be shown. 00604 LPVOID pvParam; // IN Parameter to be passed to pfnDeviceCallback as the pvParam. 00605 00606 DWORD cNumDevices; // IN number calles wants - ZERO == no limit. 00607 // OUT the number of devices returned. 00608 00609 __field_ecount_opt(cNumDevices) PBLUETOOTH_DEVICE_INFO pDevices; // OUT pointer to an array for BLUETOOTH_DEVICE_INFOs. 00610 // call BluetoothSelectDevicesFree() to free 00611 00612 } BLUETOOTH_SELECT_DEVICE_PARAMS; 00613 00614 // 00615 // Description: 00616 // (See header above) 00617 // 00618 // Return Values: 00619 // TRUE 00620 // User selected a device. pbtsdp->pDevices points to valid data. 00621 // Caller should check the fAuthenticated && fRemembered flags to 00622 // determine which devices we successfuly authenticated or valid 00623 // selections by the user. 00624 // 00625 // Use BluetoothSelectDevicesFree() to free the nessecary data 00626 // such as pDevices only if this function returns TRUE. 00627 // 00628 // FALSE 00629 // No valid data returned. Call GetLastError() for possible details 00630 // of the failure. If GLE() is: 00631 // 00632 // ERROR_CANCELLED 00633 // The user cancelled the request. 00634 // 00635 // ERROR_INVALID_PARAMETER 00636 // The pbtsdp is NULL. 00637 // 00638 // ERROR_REVISION_MISMATCH 00639 // The structure passed in as pbtsdp is of an unknown size. 00640 // 00641 // other WIN32 errors 00642 // 00643 BOOL 00644 WINAPI 00645 BluetoothSelectDevices( 00646 __inout BLUETOOTH_SELECT_DEVICE_PARAMS * pbtsdp 00647 ); 00648 00649 // 00650 // Description: 00651 // This function should only be called if BluetoothSelectDevices() returns 00652 // TRUE. This function will free any memory and resource returned by the 00653 // BluetoothSelectDevices() in the BLUETOOTH_SELECT_DEVICE_PARAMS 00654 // structure. 00655 // 00656 // Return Values: 00657 // TRUE 00658 // Success. 00659 // 00660 // FALSE 00661 // Nothing to free. 00662 // 00663 BOOL 00664 WINAPI 00665 BluetoothSelectDevicesFree( 00666 __inout BLUETOOTH_SELECT_DEVICE_PARAMS * pbtsdp 00667 ); 00668 00669 // *************************************************************************** 00670 // 00671 // Device Property Sheet 00672 // 00673 // *************************************************************************** 00674 00675 // 00676 // Description: 00677 // Invokes the CPLs device info property sheet. 00678 // 00679 // Parameters: 00680 // hwndParent 00681 // HWND to parent the property sheet. 00682 // 00683 // pbtdi 00684 // A pointer to a BLUETOOTH_DEVICE_INFO structure of the device 00685 // to be displayed. 00686 // 00687 // Return Values: 00688 // TRUE 00689 // The property page was successfully displayed. 00690 // 00691 // FALSE 00692 // Failure. The property page was not displayed. Check GetLastError 00693 // for more details. 00694 // 00695 BOOL 00696 WINAPI 00697 BluetoothDisplayDeviceProperties( 00698 __in HWND hwndParent, 00699 __inout BLUETOOTH_DEVICE_INFO * pbtdi 00700 ); 00701 00702 00703 // *************************************************************************** 00704 // 00705 // Radio Authentication 00706 // 00707 // *************************************************************************** 00708 00709 // 00710 // Description: 00711 // Sends an authentication request to a remote device. 00712 // 00713 // There are two modes of operation. "Wizard mode" and "Blind mode." 00714 // 00715 // "Wizard mode" is invoked when the pszPasskey is NULL. This will cause 00716 // the "Bluetooth Connection Wizard" to be invoked. The user will be 00717 // prompted to enter a passkey during the wizard after which the 00718 // authentication request will be sent. The user will see the success 00719 // or failure of the authentication attempt. The user will also be 00720 // given the oppurtunity to try to fix a failed authentication. 00721 // 00722 // "Blind mode" is invoked when the pszPasskey is non-NULL. This will 00723 // cause the computer to send a authentication request to the remote 00724 // device. No UI is ever displayed. The Bluetooth status code will be 00725 // mapped to a Win32 Error code. 00726 // 00727 // Parameters: 00728 // 00729 // hwndParent 00730 // The window to parent the authentication wizard. If NULL, the 00731 // wizard will be parented off the desktop. 00732 // 00733 // hRadio 00734 // A valid local radio handle or NULL. If NULL, then all radios will 00735 // be tired. If any of the radios succeed, then the call will 00736 // succeed. 00737 // 00738 // pbtdi 00739 // BLUETOOTH_DEVICE_INFO record of the device to be authenticated. 00740 // 00741 // pszPasskey 00742 // PIN to be used to authenticate the device. If NULL, then UI is 00743 // displayed and the user steps through the authentication process. 00744 // If not NULL, no UI is shown. The passkey is NOT NULL terminated. 00745 // 00746 // ulPasskeyLength 00747 // Length of szPassKey in bytes. The length must be less than or 00748 // equal to BLUETOOTH_MAX_PASSKEY_SIZE * sizeof(WCHAR). 00749 // 00750 // Return Values: 00751 // 00752 // ERROR_SUCCESS 00753 // Success. 00754 // 00755 // ERROR_CANCELLED 00756 // User aborted the operation. 00757 // 00758 // ERROR_INVALID_PARAMETER 00759 // The device structure in pbtdi is invalid. 00760 // 00761 // ERROR_NO_MORE_ITEMS 00762 // The device in pbtdi is already been marked as authenticated. 00763 // 00764 // other WIN32 error 00765 // Failure. Return value is the error code. 00766 // 00767 // For "Blind mode," here is the current mapping of Bluetooth status 00768 // code to Win32 error codes: 00769 // 00770 // { BTH_ERROR_SUCCESS, ERROR_SUCCESS }, 00771 // { BTH_ERROR_NO_CONNECTION, ERROR_DEVICE_NOT_CONNECTED }, 00772 // { BTH_ERROR_PAGE_TIMEOUT, WAIT_TIMEOUT }, 00773 // { BTH_ERROR_HARDWARE_FAILURE, ERROR_GEN_FAILURE }, 00774 // { BTH_ERROR_AUTHENTICATION_FAILURE, ERROR_NOT_AUTHENTICATED }, 00775 // { BTH_ERROR_MEMORY_FULL, ERROR_NOT_ENOUGH_MEMORY }, 00776 // { BTH_ERROR_CONNECTION_TIMEOUT, WAIT_TIMEOUT }, 00777 // { BTH_ERROR_LMP_RESPONSE_TIMEOUT, WAIT_TIMEOUT }, 00778 // { BTH_ERROR_MAX_NUMBER_OF_CONNECTIONS, ERROR_REQ_NOT_ACCEP }, 00779 // { BTH_ERROR_PAIRING_NOT_ALLOWED, ERROR_ACCESS_DENIED }, 00780 // { BTH_ERROR_UNSPECIFIED_ERROR, ERROR_NOT_READY }, 00781 // { BTH_ERROR_LOCAL_HOST_TERMINATED_CONNECTION, ERROR_VC_DISCONNECTED }, 00782 // 00783 DWORD 00784 WINAPI 00785 BluetoothAuthenticateDevice( 00786 __in_opt HWND hwndParent, 00787 __in_opt HANDLE hRadio, 00788 __inout BLUETOOTH_DEVICE_INFO * pbtbi, 00789 __out_bcount_opt(ulPasskeyLength) PWCHAR pszPasskey, 00790 ULONG ulPasskeyLength 00791 ); 00792 00793 // 00794 // Description: 00795 // Allows the caller to prompt for multiple devices to be authenticated 00796 // within a single instance of the "Bluetooth Connection Wizard." 00797 // 00798 // Parameters: 00799 // 00800 // hwndParent 00801 // The window to parent the authentication wizard. If NULL, the 00802 // wizard will be parented off the desktop. 00803 // 00804 // hRadio 00805 // A valid local radio handle or NULL. If NULL, then all radios will 00806 // be tired. If any of the radios succeed, then the call will 00807 // succeed. 00808 // 00809 // cDevices 00810 // Number of devices in the rgbtdi array. 00811 // 00812 // rgbtdi 00813 // An array BLUETOOTH_DEVICE_INFO records of the devices to be 00814 // authenticated. 00815 // 00816 // Return Values: 00817 // 00818 // ERROR_SUCCESS 00819 // Success. Check the fAuthenticate flag on each of the devices. 00820 // 00821 // ERROR_CANCELLED 00822 // User aborted the operation. Check the fAuthenticate flags on 00823 // each device to determine if any of the devices were authenticated 00824 // before the user cancelled the operation. 00825 // 00826 // ERROR_INVALID_PARAMETER 00827 // One of the items in the array of devices is invalid. 00828 // 00829 // ERROR_NO_MORE_ITEMS 00830 // All the devices in the array of devices are already been marked as 00831 // being authenticated. 00832 // 00833 // other WIN32 error 00834 // Failure. Return value is the error code. 00835 // 00836 DWORD 00837 WINAPI 00838 BluetoothAuthenticateMultipleDevices( 00839 __in_opt HWND hwndParent, 00840 __in_opt HANDLE hRadio, 00841 DWORD cDevices, 00842 __in_ecount(cDevices) BLUETOOTH_DEVICE_INFO * rgbtdi 00843 ); 00844 00845 00846 // *************************************************************************** 00847 // 00848 // Bluetooth Services 00849 // 00850 // *************************************************************************** 00851 00852 #define BLUETOOTH_SERVICE_DISABLE 0x00 00853 #define BLUETOOTH_SERVICE_ENABLE 0x01 00854 #define BLUETOOTH_SERVICE_MASK ( BLUETOOTH_ENABLE_SERVICE | BLUETOOTH_DISABLE_SERVICE ) 00855 00856 // 00857 // Description: 00858 // Enables/disables the services for a particular device. 00859 // 00860 // The system maintains a mapping of service guids to supported drivers for 00861 // Bluetooth-enabled devices. Enabling a service installs the corresponding 00862 // device driver. Disabling a service removes the corresponding device driver. 00863 // 00864 // If a non-supported service is enabled, a driver will not be installed. 00865 // 00866 // Parameters 00867 // hRadio 00868 // Handle of the local Bluetooth radio device. 00869 // 00870 // pbtdi 00871 // Pointer to a BLUETOOTH_DEVICE_INFO record. 00872 // 00873 // pGuidService 00874 // The service GUID on the remote device. 00875 // 00876 // dwServiceFlags 00877 // Flags to adjust the service. 00878 // BLUETOOTH_SERVICE_DISABLE - disable the service 00879 // BLUETOOTH_SERVICE_ENABLE - enables the service 00880 // 00881 // Return Values: 00882 // ERROR_SUCCESS 00883 // The call was successful. 00884 // 00885 // ERROR_INVALID_PARAMETER 00886 // dwServiceFlags are invalid. 00887 // 00888 // ERROR_SERVICE_DOES_NOT_EXIST 00889 // The GUID in pGuidService is not supported. 00890 // 00891 // other WIN32 error 00892 // The call failed. 00893 // 00894 DWORD 00895 WINAPI 00896 BluetoothSetServiceState( 00897 __in_opt HANDLE hRadio, 00898 const BLUETOOTH_DEVICE_INFO * pbtdi, 00899 const GUID * pGuidService, 00900 DWORD dwServiceFlags 00901 ); 00902 00903 // 00904 // Description: 00905 // Enumerates the services guids enabled on a particular device. If hRadio 00906 // is NULL, all device will be searched for the device and all the services 00907 // enabled will be returned. 00908 // 00909 // Parameters: 00910 // hRadio 00911 // Handle of the local Bluetooth radio device. If NULL, it will search 00912 // all the radios for the address in the pbtdi. 00913 // 00914 // pbtdi 00915 // Pointer to a BLUETOOTH_DEVICE_INFO record. 00916 // 00917 // pcService 00918 // On input, the number of records pointed to by pGuidServices. 00919 // On output, the number of valid records return in pGuidServices. 00920 // 00921 // pGuidServices 00922 // Pointer to memory that is at least *pcService in length. 00923 // 00924 // Return Values: 00925 // ERROR_SUCCESS 00926 // The call succeeded. pGuidServices is valid. 00927 // 00928 // ERROR_MORE_DATA 00929 // The call succeeded. pGuidService contains an incomplete list of 00930 // enabled service GUIDs. 00931 // 00932 // other WIN32 errors 00933 // The call failed. 00934 // 00935 DWORD 00936 WINAPI 00937 BluetoothEnumerateInstalledServices( 00938 __in_opt HANDLE hRadio, 00939 const BLUETOOTH_DEVICE_INFO * pbtdi, 00940 __inout DWORD * pcServices, 00941 __out_ecount_part(*pcServiceInout, *pcServiceInout) GUID * pGuidServices 00942 ); 00943 00944 // 00945 // Description: 00946 // Change the discovery state of the local radio(s). 00947 // If hRadio is NULL, all the radios will be set. 00948 // 00949 // Use BluetoothIsDiscoverable() to determine the radios current state. 00950 // 00951 // The system ensures that a discoverable system is connectable, thus 00952 // the radio must allow incoming connections (see 00953 // BluetoothEnableIncomingConnections) prior to making a radio 00954 // discoverable. Failure to do so will result in this call failing 00955 // (returns FALSE). 00956 // 00957 // Parameters: 00958 // hRadio 00959 // If not NULL, changes the state of a specific radio. 00960 // If NULL, the API will interate through all the radios. 00961 // 00962 // fEnabled 00963 // If FALSE, discovery will be disabled. 00964 // 00965 // Return Values 00966 // TRUE 00967 // State was successfully changed. If the caller specified NULL for 00968 // hRadio, at least of the radios accepted the state change. 00969 // 00970 // FALSE 00971 // State was not changed. If the caller specified NULL for hRadio, all 00972 // of the radios did not accept the state change. 00973 // 00974 BOOL 00975 WINAPI 00976 BluetoothEnableDiscovery( 00977 __in_opt HANDLE hRadio, 00978 BOOL fEnabled 00979 ); 00980 00981 // 00982 // Description: 00983 // Determines if the Bluetooth radios are discoverable. If there are 00984 // multiple radios, the first one to say it is discoverable will cause 00985 // this function to return TRUE. 00986 // 00987 // Parameters: 00988 // hRadio 00989 // Handle of the radio to check. If NULL, it will check all local 00990 // radios. 00991 // 00992 // Return Values: 00993 // TRUE 00994 // A least one radio is discoverable. 00995 // 00996 // FALSE 00997 // No radios are discoverable. 00998 // 00999 BOOL 01000 WINAPI 01001 BluetoothIsDiscoverable( 01002 __in_opt HANDLE hRadio 01003 ); 01004 01005 // 01006 // Description: 01007 // Enables/disables the state of a radio to accept incoming connections. 01008 // If hRadio is NULL, all the radios will be set. 01009 // 01010 // Use BluetoothIsConnectable() to determine the radios current state. 01011 // 01012 // The system enforces that a radio that is not connectable is not 01013 // discoverable too. The radio must be made non-discoverable (see 01014 // BluetoothEnableDiscovery) prior to making a radio non-connectionable. 01015 // Failure to do so will result in this call failing (returns FALSE). 01016 // 01017 // Parameters: 01018 // hRadio 01019 // If not NULL, changes the state of a specific radio. 01020 // If NULL, the API will interate through all the radios. 01021 // 01022 // fEnabled 01023 // If FALSE, incoming connection will be disabled. 01024 // 01025 // Return Values 01026 // TRUE 01027 // State was successfully changed. If the caller specified NULL for 01028 // hRadio, at least of the radios accepted the state change. 01029 // 01030 // FALSE 01031 // State was not changed. If the caller specified NULL for hRadio, all 01032 // of the radios did not accept the state change. 01033 // 01034 BOOL 01035 WINAPI 01036 BluetoothEnableIncomingConnections( 01037 __in_opt HANDLE hRadio, 01038 BOOL fEnabled 01039 ); 01040 01041 // 01042 // Description: 01043 // Determines if the Bluetooth radios are connectable. If there are 01044 // multiple radios, the first one to say it is connectable will cause 01045 // this function to return TRUE. 01046 // 01047 // Parameters: 01048 // hRadio 01049 // Handle of the radio to check. If NULL, it will check all local 01050 // radios. 01051 // 01052 // Return Values: 01053 // TRUE 01054 // A least one radio is allowing incoming connections. 01055 // 01056 // FALSE 01057 // No radios are allowing incoming connections. 01058 // 01059 BOOL 01060 WINAPI 01061 BluetoothIsConnectable( 01062 __in_opt HANDLE hRadio 01063 ); 01064 01065 // *************************************************************************** 01066 // 01067 // Authentication Registration 01068 // 01069 // *************************************************************************** 01070 01071 typedef HANDLE HBLUETOOTH_AUTHENTICATION_REGISTRATION; 01072 01073 typedef BOOL (*PFN_AUTHENTICATION_CALLBACK)(LPVOID pvParam, PBLUETOOTH_DEVICE_INFO pDevice); 01074 01075 // 01076 // Description: 01077 // Registers a callback function to be called when a particular device 01078 // requests authentication. The request is sent to the last application 01079 // that requested authentication for a particular device. 01080 // 01081 // Parameters: 01082 // pbtdi 01083 // A pointer to a BLUETOOTH_DEVICE_INFO structure. The Bluetooth 01084 // address will be used for comparision. 01085 // 01086 // phRegHandle 01087 // A pointer to where the registration HANDLE value will be 01088 // stored. Call BluetoothUnregisterAuthentication() to close 01089 // the handle. 01090 // 01091 // pfnCallback 01092 // The function that will be called when the authentication event 01093 // occurs. This function should match PFN_AUTHENTICATION_CALLBACK's 01094 // prototype. 01095 // 01096 // pvParam 01097 // Optional parameter to be past through to the callback function. 01098 // This can be anything the application was to define. 01099 // 01100 // Return Values: 01101 // ERROR_SUCCESS 01102 // Success. A valid registration handle was returned. 01103 // 01104 // ERROR_OUTOFMEMORY 01105 // Out of memory. 01106 // 01107 // other Win32 error. 01108 // Failure. The registration handle is invalid. 01109 // 01110 DWORD 01111 WINAPI 01112 BluetoothRegisterForAuthentication( 01113 const BLUETOOTH_DEVICE_INFO * pbtdi, 01114 __out HBLUETOOTH_AUTHENTICATION_REGISTRATION * phRegHandle, 01115 __in_opt PFN_AUTHENTICATION_CALLBACK pfnCallback, 01116 __in_opt PVOID pvParam 01117 ); 01118 01119 // 01120 // Description: 01121 // Unregisters an authentication callback and closes the handle. See 01122 // BluetoothRegisterForAuthentication() for more information about 01123 // authentication registration. 01124 // 01125 // Parameters: 01126 // hRegHandle 01127 // Handle returned by BluetoothRegisterForAuthentication(). 01128 // 01129 // Return Value: 01130 // TRUE 01131 // The handle was successfully closed. 01132 // 01133 // FALSE 01134 // The handle was not successfully closed. Check GetLastError for 01135 // more details. 01136 // 01137 // ERROR_INVALID_HANDLE 01138 // The handle is NULL. 01139 // 01140 // other Win32 errors. 01141 // 01142 BOOL 01143 WINAPI 01144 BluetoothUnregisterAuthentication( 01145 __in HBLUETOOTH_AUTHENTICATION_REGISTRATION hRegHandle 01146 ); 01147 01148 // 01149 // Description: 01150 // This function should be called after receiving an authentication request 01151 // to send the passkey response. 01152 // 01153 // Parameters: 01154 // 01155 // hRadio 01156 // Optional handle to the local radio. If NULL, the function will try 01157 // each radio until one succeeds. 01158 // 01159 // pbtdi 01160 // A pointer to a BLUETOOTH_DEVICE_INFO structure describing the device 01161 // being authenticated. This can be the same structure passed to the 01162 // callback function. 01163 // 01164 // pszPasskey 01165 // A pointer to UNICODE zero-terminated string of the passkey response 01166 // that should be sent back to the authenticating device. 01167 // 01168 // Return Values: 01169 // ERROR_SUCESS 01170 // The device accepted the passkey response. The device is authenticated. 01171 // 01172 // ERROR_CANCELED 01173 // The device denied the passkey reponse. This also will returned if there 01174 // is a communications problem with the local radio. 01175 // 01176 // E_FAIL 01177 // The device returned a failure code during authentication. 01178 // 01179 // other Win32 error codes 01180 // 01181 DWORD 01182 WINAPI 01183 BluetoothSendAuthenticationResponse( 01184 __in_opt HANDLE hRadio, 01185 const BLUETOOTH_DEVICE_INFO * pbtdi, 01186 LPCWSTR pszPasskey 01187 ); 01188 01189 // *************************************************************************** 01190 // 01191 // SDP Parsing Functions 01192 // 01193 // *************************************************************************** 01194 01195 typedef struct _SDP_ELEMENT_DATA { 01196 // 01197 // Enumeration of SDP element types. Generic element types will have a 01198 // specificType value other then SDP_ST_NONE. The generic types are: 01199 // o SDP_TYPE_UINT 01200 // o SDP_TYPE_INT 01201 // o SDP_TYPE_UUID 01202 // 01203 SDP_TYPE type; 01204 01205 // 01206 // Specific types for the generic SDP element types. 01207 // 01208 SDP_SPECIFICTYPE specificType; 01209 01210 // 01211 // Union of all possible data types. type and specificType will indicate 01212 // which field is valid. For types which do not have a valid specificType, 01213 // specific type will be SDP_ST_NONE. 01214 // 01215 union { 01216 // type == SDP_TYPE_INT 01217 SDP_LARGE_INTEGER_16 int128; // specificType == SDP_ST_INT128 01218 LONGLONG int64; // specificType == SDP_ST_INT64 01219 LONG int32; // specificType == SDP_ST_INT32 01220 SHORT int16; // specificType == SDP_ST_INT16 01221 CHAR int8; // specificType == SDP_ST_INT8 01222 01223 // type == SDP_TYPE_UINT 01224 SDP_ULARGE_INTEGER_16 uint128; // specificType == SDP_ST_UINT128 01225 ULONGLONG uint64; // specificType == SDP_ST_UINT64 01226 ULONG uint32; // specificType == SDP_ST_UINT32 01227 USHORT uint16; // specificType == SDP_ST_UINT16 01228 UCHAR uint8; // specificType == SDP_ST_UINT8 01229 01230 // type == SDP_TYPE_BOOLEAN 01231 UCHAR booleanVal; 01232 01233 // type == SDP_TYPE_UUID 01234 GUID uuid128; // specificType == SDP_ST_UUID128 01235 ULONG uuid32; // specificType == SDP_ST_UUID32 01236 USHORT uuid16; // specificType == SDP_ST_UUID32 01237 01238 // type == SDP_TYPE_STRING 01239 struct { 01240 // raw string buffer, may not be encoded as ANSI, use 01241 // BluetoothSdpGetString to convert the value if it is described 01242 // by the base language attribute ID list 01243 LPBYTE value; 01244 01245 // raw length of the string, may not be NULL terminuated 01246 ULONG length; 01247 } string; 01248 01249 // type == SDP_TYPE_URL 01250 struct { 01251 LPBYTE value; 01252 ULONG length; 01253 } url; 01254 01255 // type == SDP_TYPE_SEQUENCE 01256 struct { 01257 // raw sequence, starts at sequence element header 01258 LPBYTE value; 01259 01260 // raw sequence length 01261 ULONG length; 01262 } sequence; 01263 01264 // type == SDP_TYPE_ALTERNATIVE 01265 struct { 01266 // raw alternative, starts at alternative element header 01267 LPBYTE value; 01268 01269 // raw alternative length 01270 ULONG length; 01271 } alternative; 01272 01273 } data; 01274 01275 } SDP_ELEMENT_DATA, *PSDP_ELEMENT_DATA; 01276 01277 // 01278 // Description: 01279 // Retrieves and parses the element found at pSdpStream 01280 // 01281 // Parameters: 01282 // IN pSdpStream 01283 // pointer to valid SDP stream 01284 // 01285 // IN cbSdpStreamLength 01286 // length of pSdpStream in bytes 01287 // 01288 // OUT pData 01289 // pointer to be filled in with the data of the SDP element at the 01290 // beginning of pSdpStream 01291 // 01292 // Return Values: 01293 // ERROR_INVALID_PARAMETER 01294 // one of required parameters is NULL or the pSdpStream is invalid 01295 // 01296 // ERROR_SUCCESS 01297 // the sdp element was parsed correctly 01298 // 01299 DWORD 01300 WINAPI 01301 BluetoothSdpGetElementData( 01302 __in_bcount(cbSdpStreamLength) LPBYTE pSdpStream, 01303 ULONG cbSdpStreamLength, 01304 __out PSDP_ELEMENT_DATA pData 01305 ); 01306 01307 typedef HANDLE HBLUETOOTH_CONTAINER_ELEMENT; 01308 01309 // 01310 // Description: 01311 // Iterates over a container stream, returning each elemetn contained with 01312 // in the container element at the beginning of pContainerStream 01313 // 01314 // Parameters: 01315 // IN pContainerStream 01316 // pointer to valid SDP stream whose first element is either a sequence 01317 // or alternative 01318 // 01319 // IN cbContainerlength 01320 // length in bytes of pContainerStream 01321 // 01322 // IN OUT pElement 01323 // Value used to keep track of location within the stream. The first 01324 // time this function is called for a particular container, *pElement 01325 // should equal NULL. Upon subsequent calls, the value should be 01326 // unmodified. 01327 // 01328 // OUT pData 01329 // pointer to be filled in with the data of the SDP element at the 01330 // current element of pContainerStream 01331 // 01332 // Return Values: 01333 // ERROR_SUCCESS 01334 // The call succeeded, pData contains the data 01335 // 01336 // ERROR_NO_MORE_ITEMS 01337 // There are no more items in the list, the caller should cease calling 01338 // BluetoothSdpGetContainerElementData for this container. 01339 // 01340 // ERROR_INVALID_PARAMETER 01341 // A required pointer is NULL or the container is not a valid SDP 01342 // stream 01343 // 01344 // Usage example: 01345 // 01346 // HBLUETOOTH_CONTAINER_ELEMENT element; 01347 // SDP_ELEMENT_DATA data; 01348 // ULONG result; 01349 // 01350 // element = NULL; 01351 // 01352 // while (TRUE) { 01353 // result = BluetoothSdpGetContainerElementData( 01354 // pContainer, ulContainerLength, &element, &data); 01355 // 01356 // if (result == ERROR_NO_MORE_ITEMS) { 01357 // // We are done 01358 // break; 01359 // } 01360 // else if (result != ERROR_SUCCESS) { 01361 // // error 01362 // } 01363 // 01364 // // do something with data ... 01365 // } 01366 // 01367 // 01368 DWORD 01369 WINAPI 01370 BluetoothSdpGetContainerElementData( 01371 __in_bcount(cbContainerLength) LPBYTE pContainerStream, 01372 ULONG cbContainerLength, 01373 __inout HBLUETOOTH_CONTAINER_ELEMENT* pElement, 01374 __out PSDP_ELEMENT_DATA pData 01375 ); 01376 01377 // 01378 // Description: 01379 // Retrieves the attribute value for the given attribute ID. pRecordStream 01380 // must be an SDP stream that is formatted as an SDP record, a SEQUENCE 01381 // containing UINT16 + element pairs. 01382 // 01383 // Parameters: 01384 // IN pRecordStream 01385 // pointer to a valid SDP stream which is formatted as a singl SDP 01386 // record 01387 // 01388 // IN cbRecordlnegh 01389 // length of pRecordStream in bytes 01390 // 01391 // IN usAttributeId 01392 // the attribute ID to search for. see bthdef.h for SDP_ATTRIB_Xxx 01393 // values. 01394 // 01395 // OUT pAttributeData 01396 // pointer that will contain the attribute ID's value 01397 // 01398 // Return Values: 01399 // ERRROR_SUCCESS 01400 // Call succeeded, pAttributeData contains the attribute value 01401 // 01402 // ERROR_INVALID_PARAMETER 01403 // One of the required pointers was NULL, pRecordStream was not a valid 01404 // SDP stream, or pRecordStream was not a properly formatted SDP record 01405 // 01406 // ERROR_FILE_NOT_FOUND 01407 // usAttributeId was not found in the record 01408 // 01409 // Usage: 01410 // 01411 // ULONG result; 01412 // SDP_DATA_ELEMENT data; 01413 // 01414 // result = BluetoothSdpGetAttributeValue( 01415 // pRecordStream, cbRecordLength, SDP_ATTRIB_RECORD_HANDLE, &data); 01416 // if (result == ERROR_SUCCESS) { 01417 // printf("record handle is 0x%x\n", data.data.uint32); 01418 // } 01419 // 01420 DWORD 01421 WINAPI 01422 BluetoothSdpGetAttributeValue( 01423 __in_bcount(cbRecordLength) LPBYTE pRecordStream, 01424 ULONG cbRecordLength, 01425 USHORT usAttributeId, 01426 __out PSDP_ELEMENT_DATA pAttributeData 01427 ); 01428 01429 // 01430 // These three fields correspond one to one with the triplets defined in the 01431 // SDP specification for the language base attribute ID list. 01432 // 01433 typedef struct _SDP_STRING_TYPE_DATA { 01434 // 01435 // How the string is encoded according to ISO 639:1988 (E/F): "Code 01436 // for the representation of names of languages". 01437 // 01438 USHORT encoding; 01439 01440 // 01441 // MIBE number from IANA database 01442 // 01443 USHORT mibeNum; 01444 01445 // 01446 // The base attribute where the string is to be found in the record 01447 // 01448 USHORT attributeId; 01449 01450 } SDP_STRING_TYPE_DATA, *PSDP_STRING_TYPE_DATA; 01451 01452 // 01453 // Description: 01454 // Converts a raw string embedded in the SDP record into a UNICODE string 01455 // 01456 // Parameters: 01457 // IN pRecordStream 01458 // a valid SDP stream which is formatted as an SDP record 01459 // 01460 // IN cbRecordLength 01461 // length of pRecordStream in bytes 01462 // 01463 // IN pStringData 01464 // if NULL, then the calling thread's locale will be used to search 01465 // for a matching string in the SDP record. If not NUL, the mibeNum 01466 // and attributeId will be used to find the string to convert. 01467 // 01468 // IN usStringOffset 01469 // the SDP string type offset to convert. usStringOffset is added to 01470 // the base attribute id of the string. SDP specification defined 01471 // offsets are: STRING_NAME_OFFSET, STRING_DESCRIPTION_OFFSET, and 01472 // STRING_PROVIDER_NAME_OFFSET (found in bthdef.h). 01473 // 01474 // OUT pszString 01475 // if NULL, pcchStringLength will be filled in with the required number 01476 // of characters (not bytes) to retrieve the converted string. 01477 // 01478 // IN OUT pcchStringLength 01479 // Upon input, if pszString is not NULL, will contain the length of 01480 // pszString in characters. Upon output, it will contain either the 01481 // number of required characters including NULL if an error is returned 01482 // or the number of characters written to pszString (including NULL). 01483 // 01484 // Return Values: 01485 // ERROR_SUCCES 01486 // Call was successful and pszString contains the converted string 01487 // 01488 // ERROR_MORE_DATA 01489 // pszString was NULL or too small to contain the converted string, 01490 // pccxhStringLength contains the required length in characters 01491 // 01492 // ERROR_INVALID_DATA 01493 // Could not perform the conversion 01494 // 01495 // ERROR_NO_SYSTEM_RESOURCES 01496 // Could not allocate memory internally to perform the conversion 01497 // 01498 // ERROR_INVALID_PARAMETER 01499 // One of the rquired pointers was NULL, pRecordStream was not a valid 01500 // SDP stream, pRecordStream was not a properly formatted record, or 01501 // the desired attribute + offset was not a string. 01502 // 01503 // Other HRESULTs returned by COM 01504 // 01505 DWORD 01506 WINAPI 01507 BluetoothSdpGetString( 01508 __in_bcount(cbRecordLength) LPBYTE pRecordStream, 01509 ULONG cbRecordLength, 01510 __in_opt const PSDP_STRING_TYPE_DATA pStringData, 01511 USHORT usStringOffset, 01512 __out_ecount_part(*pcchStringLength, *pcchStringLength) PWSTR pszString, 01513 __inout PULONG pcchStringLength 01514 ); 01515 01516 // *************************************************************************** 01517 // 01518 // Raw Attribute Enumeration 01519 // 01520 // *************************************************************************** 01521 01522 typedef BOOL (CALLBACK *PFN_BLUETOOTH_ENUM_ATTRIBUTES_CALLBACK)( 01523 ULONG uAttribId, 01524 __in_bcount(cbStreamSize) LPBYTE pValueStream, 01525 ULONG cbStreamSize, 01526 LPVOID pvParam 01527 ); 01528 01529 // 01530 // Description: 01531 // Enumerates through the SDP record stream calling the Callback function 01532 // for each attribute in the record. If the Callback function returns 01533 // FALSE, the enumeration is stopped. 01534 // 01535 // Return Values: 01536 // TRUE 01537 // Success! Something was enumerated. 01538 // 01539 // FALSE 01540 // Failure. GetLastError() could be one of the following: 01541 // 01542 // ERROR_INVALID_PARAMETER 01543 // pSDPStream or pfnCallback is NULL. 01544 // 01545 // ERROR_INVALID_DATA 01546 // The SDP stream is corrupt. 01547 // 01548 // other Win32 errors. 01549 // 01550 #define BluetoothEnumAttributes BluetoothSdpEnumAttributes 01551 01552 BOOL 01553 WINAPI 01554 BluetoothSdpEnumAttributes( 01555 __in_bcount(cbStreamSize) LPBYTE pSDPStream, 01556 ULONG cbStreamSize, 01557 PFN_BLUETOOTH_ENUM_ATTRIBUTES_CALLBACK pfnCallback, 01558 __in LPVOID pvParam 01559 ); 01560 01561 #endif // (NTDDI_VERSION >= NTDDI_WINXPSP2) 01562 01563 #if (NTDDI_VERSION >= NTDDI_NTDDI_LONGHORN) 01564 01565 // 01566 // The following APIs are only available on Vista or later 01567 // 01568 01569 DWORD 01570 WINAPI 01571 BluetoothSetLocalServiceInfo( 01572 __in_opt HANDLE hRadioIn 01573 , __in const GUID * pClassGuid 01574 , ULONG ulInstance 01575 , const BLUETOOTH_LOCAL_SERVICE_INFO * pServiceInfoIn 01576 ); 01577 01578 #endif // (NTDDI_VERSION >= NTDDI_NTDDI_LONGHORN) 01579 01580 #ifdef __cplusplus 01581 } 01582 01583 01584 #endif 01585