Public Function Getstring(Hkey As Long, strPath As String, strValue As String)
Dim Keyhand As Long
Dim Datatype As Long, lResult As Long, strBuf As String
Dim lDataBufSize As Long, 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