Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Support Forum
Download Visual Studio Add-In

Terms of Use
Privacy Policy
bluetoothfindfirstradio (irprops)
 
.
Summary
Start enumerating local bluetooth radios (i.e. the devices plugged into the computer).

C# Signature:

[DllImport("irprops.cpl", SetLastError=true)]
static extern IntPtr BluetoothFindFirstRadio(ref Bluetooth_Find_Radio_Params pbtfrp,out IntPtr phRadio );

User-Defined Types:

Bluetooth_Find_Radio_Params

VB Signature:

    <DllImport("irprops.cpl", SetLastError:=True, CharSet:=CharSet.Auto)> _
    Private Shared Function BluetoothFindFirstRadio( _
    <[In]()> ByRef findRadioParams As BluetoothFindRadioParams, _
    <Out()> ByRef hRadio As IntPtr) As IntPtr
    End Function

User-Defined Types:

    Private Structure BluetoothFindRadioParams
        Public size As UInteger
        Public Sub Initialize()
                Me.size = Marshal.SizeOf(GetType(BluetoothFindRadioParams))
        End Sub    
    End Structure

Alternative Managed API:

http://32feet.net/

Notes:

XP SP1 required.

See the BluetoothAPIs.h file in the platform SDK.

Tips & Tricks:

Please add some!

Sample Code:

C#

  class Bluetooth
  {
    public Bluetooth()
    {
        BLUETOOTH_FIND_RADIO_PARAM parameters = new BLUETOOTH_FIND_RADIO_PARAM();
        parameters.Initialize();

        IntPtr firstRadio;
        IntPtr nextRadio;
        nextRadio = BluetoothFindFirstRadio(ref parameters, out firstRadio);

        //work with bluetooth
        CloseHandle(firstRadio);
        CloseHandle(nextRadio);        
    }
    /// <summary>
    /// The BLUETOOTH_FIND_RADIO_PARAMS structure facilitates enumerating installed Bluetooth radios.
    /// </summary>
    [StructLayout(LayoutKind.Sequential)]
    private struct BLUETOOTH_FIND_RADIO_PARAM
    {
        internal UInt32 dwSize;
        internal void Initialize()
        {
        this.dwSize = (UInt32)Marshal.SizeOf(typeof(BLUETOOTH_FIND_RADIO_PARAM));
        }
    }

    /// <summary>
    /// Closes an open object handle.
    /// </summary>
    /// <param name="handle">[In] A valid handle to an open object.</param>
    /// <returns>If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call GetLastError.</returns>
    [DllImport("Kernel32.dll", SetLastError = true)]
    static extern bool CloseHandle(IntPtr handle);

    /// <summary>
    /// Finds the first bluetooth radio present in device manager
    /// </summary>
    /// <param name="pbtfrp">Pointer to a BLUETOOTH_FIND_RADIO_PARAMS structure</param>
    /// <param name="phRadio">Pointer to where the first enumerated radio handle will be returned. When no longer needed, this handle must be closed via CloseHandle.</param>
    /// <returns>In addition to the handle indicated by phRadio, calling this function will also create a HBLUETOOTH_RADIO_FIND handle for use with the BluetoothFindNextRadio function.
    /// When this handle is no longer needed, it must be closed via the BluetoothFindRadioClose.
    /// Returns NULL upon failure. Call the GetLastError function for more information on the error. The following table describe common errors:</returns>
    [DllImport("irprops.cpl", SetLastError = true)]
    static extern IntPtr BluetoothFindFirstRadio(ref BLUETOOTH_FIND_RADIO_PARAM pbtfrp, out IntPtr phRadio);
  }

Documentation

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version
Revisions