Newsgroup: it.comp.lang.visual-basic
Titolo: Accesso remoto.

Avrei la necessità di testare se è attiva una connessione a internet e in
caso negativo devo poter attivare una connessione remoto o già creata sulla
macchina in questione oppure anche specificando modem, utente, pwd e numero
di telefono per attivarne una nuova.
Come posso realizzare un applicativo del genere?
Daniele Bordino
-- 
Posted from 
smtp1.libero.it
 [193.70.192.51] 
via Mailgate.ORG Server - 
http://www.Mailgate.ORG

Non vorrei tirare una castronata, ma sul sito di Moreno c'è un articolo che
magari potrebbe servirti.
http://www.morenosoft.com/MSVBSite/download.asp?lang=Ita&type=4&ID=27
CiaoZ
SebaMix

Daniele Bordino
devi leggere questa chiave
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\RemoteAccess
ti butto qui un codice cheho scritto tempo fa e potrebbe fare al caso
tuo. (spero funzioni!!)
''''''''''''''''''''''''''''''''''''''''''''
    Declare Function RegCloseKey Lib "advapi32.dll" ( _
        ByVal hKey As Long _
    ) As Long
    Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA"
( _
        ByVal hKey As Long, _
        ByVal lpSubKey As String, _
        phkResult As Long _
    ) As Long
 
    Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias
"RegOpenKeyExA" ( _
       ByVal hKey As Long, ByVal lpSubKey As String, _
       ByVal dwOptions As Long, ByVal samDesired As Long, _
       phkResult As Long _
    ) As Long
    Declare Function RegQueryValueEx 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
 
 
 
    Declare Function RegSetValueExString Lib "advapi32.dll" Alias
"RegSetValueExA" ( _
       ByVal hKey As Long, _
       ByVal lpValueName As String, _
       ByVal Reserved As Long, _
       ByVal dwType As Long, _
       ByVal lpData As String, _
       ByVal cbData As Long _
   ) As Long
    Const ERROR_SUCCESS = 0&
    Const APINULL = 0&
    Const HKEY_LOCAL_MACHINE = &H80000002
    ' key constants
 
    Public Const KEY_ENUMERATE_SUB_KEYS = &H8
    Public Const KEY_NOTIFY = &H10
    Public Const KEY_QUERY_VALUE = &H1
    Public Const SYNCHRONIZE = &H100000
    Public Const READ_CONTROL = &H20000
    Public Const STANDARD_RIGHTS_READ = (READ_CONTROL)
    Public Const STANDARD_RIGHTS_WRITE = (READ_CONTROL)
    Public Const STANDARD_RIGHTS_ALL = &H1F0000
    Public Const KEY_READ = ((STANDARD_RIGHTS_READ Or KEY_QUERY_VALUE
Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY) And (Not SYNCHRONIZE))
    Public Const REG_OPTION_NON_VOLATILE = 0
    Public Const KEY_CREATE_SUB_KEY = &H4
    Public Const KEY_CREATE_LINK = &H20
    Public Const KEY_SET_VALUE = &H2
    Public Const KEY_WRITE = ((STANDARD_RIGHTS_WRITE Or KEY_SET_VALUE
Or KEY_CREATE_SUB_KEY) And (Not SYNCHRONIZE))
    Public Const KEY_ALL_ACCESS = ((STANDARD_RIGHTS_ALL Or
KEY_QUERY_VALUE Or KEY_SET_VALUE Or KEY_CREATE_SUB_KEY Or
KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY Or KEY_CREATE_LINK) And (Not
SYNCHRONIZE))
    Public Const REG_OPTION_VOLATILE = 1
    ' Types
    Public Const REG_SZ = 1
    Public Const REG_DWORD = 4
'
'
'''''''''''''''''''''''
Public Function ActiveConnection() As Boolean
'''''''
'  nel registro c'e' una chiave in cui viene registrato se
'  c'e' una connessione attiva. Questa funzione verifica il valore
'  della chiave e ritorna il valore corrispondente
'''''''
Dim hKey As Long
Dim lpSubKey As String
Dim phkResult As Long
Dim lpValueName As String
Dim lpReserved As Long
Dim lpType As Long
Dim lpData As Long
Dim lpcbData As Long
Dim ReturnCode As Long
ActiveConnection = False
lpSubKey = "System\CurrentControlSet\Services\RemoteAccess"
ReturnCode = RegOpenKey(HKEY_LOCAL_MACHINE, lpSubKey, phkResult)
If ReturnCode = ERROR_SUCCESS Then
    hKey = phkResult
    lpValueName = "Remote Connection"
    lpReserved = APINULL
    lpType = APINULL
    lpData = APINULL
    lpcbData = APINULL
 
    ReturnCode = RegQueryValueEx(hKey, lpValueName, lpReserved,
lpType, ByVal lpData, lpcbData)
    lpcbData = Len(lpData)
    ReturnCode = RegQueryValueEx(hKey, lpValueName, lpReserved,
lpType, lpData, lpcbData)
        If ReturnCode = ERROR_SUCCESS Then
            If lpData = 0 Then
                ActiveConnection = False
            Else
                ActiveConnection = True
            End If
        End If
    RegCloseKey (hKey)
End If
End Function

 Come posso realizzare un applicativo del genere?
sul sito comune c'è un esempio molto valido di Moreno S. scaricatelo..si
chiama
ACCESSO REMOTO!
Ciao Simo

Altro che castronata, ti ringrazio, mi hai risolto il problema.
