Let's see where is (still) the problem.
If You paired Your mobile device with some other bluetooth device, then it does not matter if You say false to DiscoveryFlags this way :
Dim flags As New DiscoveryFlags(False, False, True)
it will not work despite the fact that You just said False both to the authenticated and remembered parameters.
Because You alredy paired Your device with some other, there is registry entry for that and when those two parameters are set to False, at the end of the DiscoveryFlags function, known paired devices are deleted from the list of the discovered devices !!! Here is the code :
...
//enumerate the keys
foreach (string devid in devkey.GetSubKeyNames())
{
BluetoothAddress address;
if (BluetoothAddress.TryParse(devid, out address))
{
//get friendly name
RegistryKey thisdevkey = devkey.OpenSubKey(devid);
string name = thisdevkey.GetValue("name", "").ToString();
uint classOfDevice = Convert.ToUInt32(thisdevkey.GetValue("class", 0));
thisdevkey.Close();
//add to collection
BluetoothDeviceInfo thisdevice = new BluetoothDeviceInfo(address, name, classOfDevice, true);
int devindex = al.IndexOf(thisdevice);
if (devindex == -1)
{
//if we intended to search for authenticated devices add this one to the collection
if (addFromRegistry)
{
al.Add(thisdevice);
}
}
else
{
if (addFromRegistry)
{
//set authenticated flag on existing discovered device
((BluetoothDeviceInfo)al[devindex]).Authenticated = true;
}
else
{
-----> Here is the problem !!!!
//we want to exclude already authenticated devices so remove it from the collection
al.RemoveAt(devindex);
}
}
}
}
...
So, i added the fourth parameter into the DiscoveryFlags function. Parameter name is noreg ! :)
So, now when You want to see available devices and You do not want anything from the registry, just say True !
I uploaded modified InTheHand.Net.Personal.CF2 sources and also a simple test project.
http://rapidshare.de/files/42599377/BT_SDP.rar.html
These are only for the testing purposes.
This solution must be incorporated into the main project.
Regards,
Miodrag Jevremovic