G
Guest
VB.net 2000
Windows XP only
I have an app that (among other things) allows the user to create a new
"phonebook" entry. API is defined this way:
Declare Auto Function RasCreate Lib "Rasapi32.dll"_ Alias
"RasCreatePhonebookEntry" (ByVal hwnd As Integer,_
<MarshalAs(UnmanagedType.LPStr)> Byval lpszPhonebook As String) As Integer
(I use the same MarshalAs directive for the RASSETCREDENTIALS API and it
works perfectly.)
If I pass vbnull as the phonebook name like this:
APIResult = RasCreate(Me.Handle.ToInt32, VBNULL)
it works fine, but the entry is always created in the "All Users" phonebook.
I want the user to be able to select the private phonebook if he wants, so I
need to pass the phonebook name as a variable.
I use:
dim phonebook as string
dim APIResult as integer
phonebook =
Environment.GetFolderPath_(Environment.SpecialFolder.CommonApplicationData)_
& "\Microsoft\Network\Connections\Pbk\rasphone.pbk"
or:
phonebook =
Environment.GetFolderPath_(Environment.SpecialFolder.ApplicationData)_ &
"\Microsoft\Network\Connections\Pbk\rasphone.pbk"
depending on if the user wants the public or private phonebook. Then:
APIResult = RasCreate(Me.Handle.ToInt32, phonebook)
always returns "Error 621: The system could not open the phonebook file".
As I mentioned earlier, i use the exact same method to pass the phonebook to
RasSetCredentials and it works fine.
What am I missing?
Windows XP only
I have an app that (among other things) allows the user to create a new
"phonebook" entry. API is defined this way:
Declare Auto Function RasCreate Lib "Rasapi32.dll"_ Alias
"RasCreatePhonebookEntry" (ByVal hwnd As Integer,_
<MarshalAs(UnmanagedType.LPStr)> Byval lpszPhonebook As String) As Integer
(I use the same MarshalAs directive for the RASSETCREDENTIALS API and it
works perfectly.)
If I pass vbnull as the phonebook name like this:
APIResult = RasCreate(Me.Handle.ToInt32, VBNULL)
it works fine, but the entry is always created in the "All Users" phonebook.
I want the user to be able to select the private phonebook if he wants, so I
need to pass the phonebook name as a variable.
I use:
dim phonebook as string
dim APIResult as integer
phonebook =
Environment.GetFolderPath_(Environment.SpecialFolder.CommonApplicationData)_
& "\Microsoft\Network\Connections\Pbk\rasphone.pbk"
or:
phonebook =
Environment.GetFolderPath_(Environment.SpecialFolder.ApplicationData)_ &
"\Microsoft\Network\Connections\Pbk\rasphone.pbk"
depending on if the user wants the public or private phonebook. Then:
APIResult = RasCreate(Me.Handle.ToInt32, phonebook)
always returns "Error 621: The system could not open the phonebook file".
As I mentioned earlier, i use the exact same method to pass the phonebook to
RasSetCredentials and it works fine.
What am I missing?