Click to See Complete Forum and Search --> : bug in Windows Shell object?


jeffmcln5
March 29th, 2004, 04:27 AM
Hello,

I'm trying to retrieve the contents of the folder "\My Bluetooth Places\Entire Bluetooth Neighborhood" to see my local Bluetooth devices. I can use the Shell class to access teh "My Bluetooth Places" folder, but the Items collection is empty (which is wrong--it *does* contain "Entire Bluetooth Neighborhood"). If I call BrowseForFolder it lists the folder correctly and I can pick it. But, if you see how many children it's parent contains, it says it's 0. What??? How can your parent not have any children? That's got to be a bug, right?

Also, once you find the Bluetooth device, it has a property "Mac Address" (you can right click on it in explorer and choose properties to see it). Is there any way to get this value programatically?

Here's a C# code snippet:


Shell32.ShellClass shell = new Shell32.ShellClass();

// This will bring up a Folder browser. Pick "\My Bluetooth Places\Entire Bluetooth Neighborhood"
Shell32.Folder fEntire_Bluetooth_Neighborhood =
shell.BrowseForFolder(0,"Pick Entire Bluetooth Neighboorhood",0,null);

Shell32.Folder fMy_Bluetooth_Places = fEntire_Bluetooth_Neighborhood.ParentFolder;

// Now fMy_Bluetooth_Places points to My Bluetooth Places
// and fEntire_Bluetooth_Neighborhood points to My Bluetooth Places\Entire Bluetooth Neighborhood

Shell32.FolderItems childItems = fMy_Bluetooth_Places.Items(); // take the child folder, see how many items the parent contains
int Count = childItems.Count; // Count is 0. How's that possible? My parent has no children?

Sam Hobbs
March 29th, 2004, 08:39 PM
People are usually wrong when they think there is a bug. It is easy to blame Windows or Microsoft instead of diagnosing the problem. Regardlous, this is a forum for C++, not C#.

jeffmcln5
March 30th, 2004, 07:54 AM
Whether you use C++ or C#, either way it just resolves to a single call within the shell32.dll. I can do the same thing in C++ and it gives me the same results, because either way it's just calling the exported function in shell32.dll. I can write it in C, C++, C#, assembler, VB, any language at all that calls exported fucntions from .dll's, and it makes no difference--the problem is that shell32.dll returns an incorrect response. I posted the code in C# because it's more compact.

You say I should try to 'diagnose' it. But it's just a single function call into shell32.dll. And shell32.dll is returning an incorrect response. Since my code just makes a call to shell32.dll and all the logic is in shell32.dll, how am I supposed to diagnose it? I do not have the source code to shell32.dll. Do you have it? Since the function that is failing and is returning an invalid response is in shell32.dll and MS wrote shell32.dll, that's why I suggested it was a bug in MS code. If you have the source code for shell32 so I can step through it (because that's the only place where the logic resides) I'll be happy to diagnose it myself.

Sam Hobbs
March 30th, 2004, 09:48 AM
If it's a bug then we can't fix it. You need to report it to Microsoft instead of here. If it is not a bug then insisting it is means you won't do what needs to be done to determine what the problem really is.