06300315.txt 30-Jun-00


Problem RegEnumValue() & NT

Hi,

i've a problem with the winapi-func RegEnumValue() under NT.
i wrote an app which gets all the registry entries of an
  odbc-datasource and puts them into a textfile.
this app works fine in win 95/98 but doesn't work in nt.
under nt it doesn't even show the list of the configured
  odbc-datasources.
i'm using a registry class based on the Class_Registry from
  KnowVow ('regclass').
i added a method which returns an array containing all the
  values of an specified subkey (like the method
  Get_SubKey_ValueNames() just using the api-func
  RegEnumValue())
as said before this works fine under win95/98 but not under
  nt, and i've no idea why.
maybe it's the different version of the advapi32.dll?
can anybody help me?

TIA
markus mitterauer


Have you checked the security access to the registry?

Dirk


Hi Markus,

maybe the key is stored on another section. NT and W95/98
  are different in the registry,  or permisson is denied, or
  ....
You should ask for the return code of RegEnumValue() (even
  for all API calls) and when != ERROR_SUCCESS you have a
  problem. The return code is the error code and if you like
  a more readable message what this error means you can call
  API FormatMessage()

Ahoj


Markus,

You may want to try something from this function I use
  (works on NT as far as I can tell)...
Function GetFoxProDataSourceName()
  local cSubKeyName as string
  lcoal aDesiredDrivers := { "FOXPRO FILES", ;
    "VISUAL FOXPRO TABLES"} as array
  local i, nSubKeys,nMaxSubKeyLength, ;
    nCurrentSubKeyLength as DWORD
  local cTmp AS STRING
  i := RegOpenKeyEx(HKEY_CURRENT_USER,;
    Psz(_CAST,"Software\ODBC\ODBC.INI"), 0, ;
    KEY_QUERY_VALUE+KEY_ENUMERATE_SUB_KEYS,@hKey)
  i := RegOpenKeyEx(HKEY_CURRENT_USER,;

    Psz(_CAST,"Software\ODBC\ODBC.INI"), 0, ;
    KEY_QUERY_VALUE+KEY_ENUMERATE_SUB_KEYS,@hKey)
  IF i == ERROR_SUCCESS
    if RegQueryInfoKey(hKey, NULL_PSZ, NULL_PTR, ;
      NULL_PTR, @nSubKeys, @nMaxSubKeyLength,;
      NULL_PTR, NULL_PTR, NULL_PTR, NULL_PTR,;
      NULL_PTR, NULL_PTR) == ERROR_SUCCESS
      nSubKeys := nSubKeys - 1
      nMaxSubKeyLength := nMaxSubKeyLength + 2
      for i := 0 upto nSubKeys
        nCurrentSubKeyLength := nMaxSubKeyLength
        cSubKeyName := Space(nMaxSubKeyLength)
        if RegEnumKeyEx(hKey, i,;
          String2Psz(cSubKeyName), @nCurrentSubKeyLength,;
          NULL_PTR, NULL_PTR, NULL_PTR, NULL_PTR);
          == ERROR_SUCCESS
          cTmp := Trim(Psz2String(String2Psz(cSubKeyName)))
          IF AScan(aDesiredDrivers,Upper(cTmp)) > 0
            RETURN cTmp
          ENDIF
        endif
      next i
    endif
    RegCloseKey(hKey)
  endif

Cheers
Gerard