1
« en: Miércoles 23 de Mayo de 2007, 11:57 »
Que cambia en VB.NET de la funcion de api regQueryValueEx
Private 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 ' Note that if you declare the lpData parameter as String, you must pass it By Value.
lo he cambiado en .NET asi pero nose si esta correcto:
Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Integer, ByVal lpValueName As String, ByVal lpReserved As Integer, ByRef lpType As Integer, ByRef lpData As String, ByRef lpcbData As Integer) As Integer ' Note that if you declare the lpData parameter as String, you must pass it By Value.
Tengo el siguiente codigo donde utilizo la funcion pero no consigo que me devuelva 0:
Dim nRet As Integer
Dim hKey As Integer
Dim nType As Integer
Dim nBytes As Integer
Dim Buffer As String
' Open key
nRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE, SubKey(Section), 0, KEY_ALL_ACCESS, hKey)
If nRet = ERROR_SUCCESS Then
' Set appropriate value for default query
If Key = "*" Then Key = vbNullString
' Determine how large the buffer needs to be
Buffer = ""
nRet = RegQueryValueEx(hKey, Key, 0, nType, Buffer, nBytes)
La variable nRet en la ultima linea necesito que me devuelva 0 para que me de el valor de la clave del registro.
Aver si alguien me puede ayudar.Gracias