ok i have some code in a dll and when i call it it nothing happens, i mean it should return the data but its not, i can put thesame code in the exe and it works fine.

VB Code:
  1. Public Function GetSettingString(hKey As Long, strPath As String, strValue As String, Optional Default As String) As String
  2. Dim hCurKey As Long
  3. Dim lValueType As Long
  4. Dim strbuffer As String
  5. Dim lDataBufferSize As Long
  6. Dim intZeroPos As Integer
  7. Dim lRegResult As Long
  8. ' Set up default value
  9. If Not IsEmpty(Default) Then
  10.   GetSettingString = Default
  11. Else
  12.   GetSettingString = ""
  13. End If
  14. ' Open the key and get length of string
  15. lRegResult = RegOpenKey(hKey, strPath, hCurKey)
  16. lRegResult = RegQueryValueEx(hCurKey, strValue, 0&, lValueType, ByVal 0&, lDataBufferSize)
  17. If lRegResult = ERROR_SUCCESS Then
  18.   If lValueType = REG_SZ Then
  19.     ' initialise string buffer and retrieve string
  20.     strbuffer = String(lDataBufferSize, " ")
  21.     lRegResult = RegQueryValueEx(hCurKey, strValue, 0&, 0&, ByVal strbuffer, lDataBufferSize)
  22.     ' format string
  23.     intZeroPos = InStr(strbuffer, Chr$(0))
  24.     If intZeroPos > 0 Then
  25.       GetSettingString = Left$(strbuffer, intZeroPos - 1)
  26.     Else
  27.       GetSettingString = strbuffer
  28.     End If
  29.   End If
  30. Else
  31.   ' there is a problem
  32. End If
  33. lRegResult = RegCloseKey(hCurKey)
  34. End Function