Necesito Ayuda URGENTE!
Hola que tal, necesito urgente que alguien por favor me diga como modificar el valor de la Clave "ProxyServer" que se encuentra en "HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionInternet Settings"
Necesito modificar la clave "ProxyServer" con el valor que tengo en mi Text1.text.
Alguien me podría decir como puedo hacerlo?.
Saludos!!
Diego desde Argentina
Necesito modificar la clave "ProxyServer" con el valor que tengo en mi Text1.text.
Alguien me podría decir como puedo hacerlo?.
Saludos!!
Diego desde Argentina
Coloque lo siguiente en un módulo estándar:
Private Const ERROR_SUCCESS As Long = 0&
Private Const HKEY_CURRENT_USER As Long = &H80000001
Private Const KEY_SET_VALUE As Long = &H2
Private Const REG_SZ As Long = 1
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private 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
Private 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 function ActualizarProxyServer(byval strNuevo as string) as boolean
const strClave = "SoftwareMicrosoftWindowsCurrentVersionInternet Settings"
dim hKey as long
if (RegOpenKeyEx(HKEY_CURRENT_USER, strClave, 0, KEY_SET_VALUE, hKey) <> ERROR_SUCCESS)then
Actualizarproxyserver = false
exit function
endif
if (RegSetValueEx(hKey, "ProxyServer", 0, REG_SZ, byval strNuevo, len(strNuevo))<> ERROR_SUCCESS) then
Regclosekey hkey
ActualizarProxyServer = false
exit function
endif
regclosekey hkey
actualizarProxyserver = true
end function
'Fin de módulo.
Ahora, cada vez que quiera actualizar el valor ProxyServer, hace esto:
if not(ActualizarProxyServer(text1.text)) then
msgbox "No se pudo actualizar el valor!", vbcritical
endif
SUPOSICIONES:
1. "ProxyServer" es un valor de la clave mencionada.
2. El tipo de valor del valor de clave "ProxyServer" es TEXTO (string).
Hice estas suposiciones porque my máquina no muestra ninguna subclave llamada ProxyServer, ni ningún valor de clave llamado así. Además, en mi máquina, la configuración del proxy parece estar en distintos valores de clave, no en subclaves.
Private Const ERROR_SUCCESS As Long = 0&
Private Const HKEY_CURRENT_USER As Long = &H80000001
Private Const KEY_SET_VALUE As Long = &H2
Private Const REG_SZ As Long = 1
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private 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
Private 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 function ActualizarProxyServer(byval strNuevo as string) as boolean
const strClave = "SoftwareMicrosoftWindowsCurrentVersionInternet Settings"
dim hKey as long
if (RegOpenKeyEx(HKEY_CURRENT_USER, strClave, 0, KEY_SET_VALUE, hKey) <> ERROR_SUCCESS)then
Actualizarproxyserver = false
exit function
endif
if (RegSetValueEx(hKey, "ProxyServer", 0, REG_SZ, byval strNuevo, len(strNuevo))<> ERROR_SUCCESS) then
Regclosekey hkey
ActualizarProxyServer = false
exit function
endif
regclosekey hkey
actualizarProxyserver = true
end function
'Fin de módulo.
Ahora, cada vez que quiera actualizar el valor ProxyServer, hace esto:
if not(ActualizarProxyServer(text1.text)) then
msgbox "No se pudo actualizar el valor!", vbcritical
endif
SUPOSICIONES:
1. "ProxyServer" es un valor de la clave mencionada.
2. El tipo de valor del valor de clave "ProxyServer" es TEXTO (string).
Hice estas suposiciones porque my máquina no muestra ninguna subclave llamada ProxyServer, ni ningún valor de clave llamado así. Además, en mi máquina, la configuración del proxy parece estar en distintos valores de clave, no en subclaves.
