Get list of phonebook entries

Oct 19, 2009 at 5:49 PM


I'm having some troubles trying to lst the phonebook entries for the current user in Windows 7. (Yes Jeff, I know you don't support this yet, I'm just hoping someone has found a way for this to work :) )
It keeps giving me the (presumably) default phonebook from the directory 'c:\ProgramData\Microsoft\Network\Connections\Pbk\'.
I've set the phonebookpath property on the dialer to RasPhoneBook.GetPhoneBookPath(RasPhoneBookType.User), so when I insert an entryname in the code it is able to connect to it. But I would like to have a list of available entries for the current user in a combobox.

Anyone that has found a way to list the entries for the current user?

Thanks in advance.


Oct 19, 2009 at 6:04 PM

Lol, I'm glad you put that disclaimer there because I just about started ranting after I saw Windows 7.

If you call Open() on the RasPhoneBook it always opens the phonebook for the all users profile, which is at the location you mentioned in your original post. If you want to get access to the user specific entries, you can call one of the other overloads on the Open method which (presumably) should give you the entries for that particular user. Whether or not they work I can't say for certain, but that's how it works on the supported platforms.

Windows has 2 phonebooks open at a given time when you look at the Network Connections window, the all users and current users profile phonebooks.

Think I need to rename the class to RasPhonebook since I don't even separate the words consistently, lol.

Oct 19, 2009 at 7:01 PM

hehe, I saw some of your earlier replies about win 7 :)

But I've got it working now. I guess I missed the overload on the .Open method.

Here's what works for me :

RasPhoneBook aPB = new RasPhoneBook();
foreach (RasEntry entry in aPB.Entries)
   this.ConnectionsComboBox.Items.Add(new ComboBoxItem(entry.Name, entry.Id));