I have 2 questions:
1) Before an "vb-automatic RAS connection" on a win98 pc, I delete an
"RAS-ICON" (no problem to understand with the sample code). Then, I
recreate the Icon (cause the password has been changed... anyway...), but
now I don't get how to create an entry... I have copied the
VBRasSetEntryProperties function and I called it like you see here:
Dim clsVBRasEntry As VBRasEntry
Dim rtn As Long
rtn = Entry.VBRasSetEntryProperties("NewEntry", clsVBRasEntry)
If rtn <> 0 Then debug.print VBRASErrorHandler(rtn)
'However this work OK!...
Call VBRasGetEntryProperties("AnExistantEntry", clsVBRasEntry)
debug.print clsVBRasEntry.AreaCode
debug.print clsVBRasEntry.LocalPhoneNumber
So what is missing do I have only to prepare the structure? With "options",
"Phonebook"? if HOW??? Could you give me a sample of what is missing to
get an new entry, please?
2) The next problem comming up will be about the call time-out... I really
don't how to add this feature within my program!!!! I have some idea but if
I follow theses, I would need a help... what I see for now is to modify the
modem's call time-out... so if you have easiest way to check for the
time-out, please send me!
THANK YOU VERY MUCH FOR YOUR HELP.
Jean-Claude Bertrand
"To successfully create a new entry, you will probably have to declare some
of it's parameters such as Options, LocalPhoneNumber, DeviceName,
DeviceType, fNetProtocols, and/or FramingProtocol."
in other words set these options before trying to create a new entry.
DeviceName and DeviceType are needed for 95/98, I don't think NT requires
them. You can get them from RasEnumDevices or from an existing entry.
--
Bill McCarthy, MVP VB
Total Environment
www.TotalEnviro.com/PlatformVB
"Jean-Claude Bertrand" <bertr...@hotmail.com> wrote in message
news:XDtc4.28806$B6.1...@quark.idirect.com...
However, if you are working with RAS, each entry can set it's default
settings for idle disconnection time and cancel if not connected within so
many seconds. I haven't got NT loaded here (that poor old hard disk died a
horrible death), so I can only test on win 98 which should hopefully also
work on win95, but i'll leave that up to you to test (I no longer support
win95 'cause as if they can't afford to upgrade they can't afford to support
me <g>) On Nt you will have to go about it a totally different way, but
much can be done directly through RAS. Anyway on 98 you can do this via the
registry and a bit of byte crunching, here's the code:
Public Const HKEY_CURRENT_USER = &H80000001
Public Const KEY_ReadWrite = &H2000F
Public Declare Function RegCloseKey _
Lib "advapi32.dll" (ByVal hKey As Long) As Long
Public Declare Function RegOpenKeyEx _
Lib "advapi32.dll" Alias "RegOpenKeyExA" _
(ByVal hKey As Long, ByVal lpSubKey As String, _
ByVal ulOptions As Long, ByVal samDesired As Long, _
phkResult As Long) As Long
Public Declare Function RegQueryValue _
Lib "advapi32.dll" Alias "RegQueryValueExA" _
(ByVal hKey As Long, ByVal lpValueName As String, _
ByVal lpReserved As Long, lpType As Long, _
lpData As Any, lpcbData As Long) As Long
Public Declare Function RegSetValueEx _
Lib "advapi32.dll" Alias "RegSetValueExA" _
(ByVal hKey As Long, ByVal lpValueName As String, _
ByVal Reserved As Long, ByVal dwType As Long, _
lpData As Any, ByVal cbData As Long) As Long
Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _
(Destination As Any, Source As Any, ByVal Length As Long)
Sub SetEntryTimeOuts(strEntryName As String, lngConnTimeOut As Long,
lngIdleTimeOut As Long)
'lngConnTimeOut is in seconds - Cancel if not connected within...
' lngConnTimeOut must be less than 255 - 16 ?
'lngIdleTimeOut is in minutes - disconnect if idle for....
' lngIdleTimeOut < 999 minutes
Dim hKey As Long, rtn As Long, lpcbData As Long, lpType As Long
Dim b() As Byte, bTemp(3) As Byte
Dim i As Long, j As Long
On Error GoTo MustCloseKey
rtn = RegOpenKeyEx(HKEY_CURRENT_USER, "RemoteAccess\Addresses", _
KEY_ReadWrite, 0&, hKey)
rtn = RegQueryValue(hKey, strEntryName, 0&, ByVal 0&, ByVal 0&, lpcbData)
ReDim b(lpcbData - 1)
rtn = RegQueryValue(hKey, strEntryName, 0&, lpType, b(0), lpcbData)
'get old settings just for fun
Debug.Print "Previous settings:"
For i = 0 To 3
bTemp(i) = b(291 + i) Xor &H10
Next i
CopyMemory j, bTemp(0), 4
Debug.Print "Cancel if not connected within " & j & " seconds"
For i = 0 To 3
bTemp(i) = b(295 + i) Xor &H10
Next i
CopyMemory j, bTemp(0), 4
Debug.Print "Disconnect if idle for " & j \ 60 & " minutes"
' apply new settings
CopyMemory bTemp(0), lngConnTimeOut, 4
For i = 0 To 3
b(291 + i) = bTemp(i) Xor &H10
Next i
j = lngIdleTimeOut * 60
CopyMemory bTemp(0), j, 4
For i = 0 To 3
b(295 + i) = bTemp(i) Xor &H10
Next i
rtn = RegSetValueEx(hKey, strEntryName, 0&, lpType, b(0), lpcbData)
MustCloseKey:
rtn = RegCloseKey(hKey)
End Sub