All pastes #112002 Raw Edit

Stuff

public text v1 · immutable
·published 2006-08-02 16:37 UTC
rendered paste body
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