Visual Basic - Ayuda alguien que sepaa!!! (REGISTRO)

Life is soft - evento anual de software empresarial
 
Vista:

Ayuda alguien que sepaa!!! (REGISTRO)

Publicado por *n4pZt3r* (31 intervenciones) el 04/01/2005 15:53:04
Hola a todos y gracias de antemano. Necesito saber el código para cargar el valor de una clave del registro a un string, o un txtbox (da igual, el caso es cargarlo) Necesito completar algo asi:

Dim valor As String
valor = AQUÍ EL CÓDIGO PARA COGER UN VALOR DEL REGISTRO

Muchas gracias de nuevo por CUALQUIER ayuda
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

Sólo para tomar String

Publicado por Benjo (679 intervenciones) el 04/01/2005 22:07:19
Public Const HKEY_CLASSES_ROOT = &H80000000
Public Const HKEY_CURRENT_USER = &H80000001
Public Const HKEY_LOCAL_MACHINE = &H80000002
Public Const HKEY_USERS = &H80000003
Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal Hkey As Long, ByVal lpSubKey As String, 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
Public Const ERROR_SUCCESS = 0&
Public Const REG_SZ = 1
' Hkey=HKEY_ ....... -strPath=Clave de Registro - strValue=Valor del Registro
Public Function getstring(Hkey As Long, strPath As String, strValue As String)
Dim keyhand As Long
Dim datatype As Long
Dim lResult As Long
Dim strBuf As String
Dim lDataBufSize As Long
Dim intZeroPos As Integer
r = RegOpenKey(Hkey, strPath, keyhand)
lResult = RegQueryValueEx(keyhand, strValue, 0&, lValueType, ByVal 0&, lDataBufSize)
If lValueType = REG_SZ Then
strBuf = String(lDataBufSize, " ")
lResult = RegQueryValueEx(keyhand, strValue, 0&, 0&, ByVal strBuf, lDataBufSize)
If lResult = ERROR_SUCCESS Then
intZeroPos = InStr(strBuf, Chr$(0))
If intZeroPos > 0 Then
getstring = Left$(strBuf, intZeroPos - 1)
Else
getstring = strBuf
End If
End If
End If
End Function
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar