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