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