KEY_ALL_ACCESS
Announcement
Collapse
No announcement yet.
Reading from Registry
Collapse
X
-
-
Try putting source code in [ code ] tags (without the space), not in [ quote ] tags. Code tags use a fixed width font and preserve code formating (indention).
Leave a comment:
-
Found the reason:
correct code is
REGENUMVALUE( hKey, dcnt, szClass, %MAX_PATH, BYVAL 0&, BYVAL 0&, szValue, %MAX_PATH)
Werner
Leave a comment:
-
Reading from Registry
Its the first time I am trying to read keys / values from the registry and ended in a problem I was not able to solve. The following code runs ok under '98 SE but does not return keys and values under XP
regKey = "Software\ODBC\ODBC.INI"
lResult = REGOPENKEYEX( %HKEY_LOCAL_MACHINE, regKey, BYVAL 0&, %KEY_READ, hKey )
DO WHILE REGENUMKEYEX( hKey, isubkey, szKeyName, %MAX_PATH, dwReserved, szClass, %MAX_PATH, Lastwrite ) = %ERROR_SUCCESS
COMBOBOX ADD CBHNDL, %IDC_ODBCDB, szKeyName
INCR iSubKey
LOOP
COMBOBOX SELECT CBHNDL, %IDC_ODBCDB, 1
REGCLOSEKEY( hKey )
regKey = "SOFTWARE\ODBC\ODBC.INI\" + sText
lResult = REGOPENKEYEX( %HKEY_LOCAL_MACHINE, regKey, BYVAL 0&, %KEY_ALL_ACCESS, hKey )
IF lResult = %ERROR_SUCCESS THEN
szClass= space$(%MAX_PATH)
szVALUE= space$(%MAX_PATH)
DO WHILE REGENUMVALUE( hKey, cnt, szClass, %MAX_PATH, dwReserved, %REG_NONE, szValue, %MAX_PATH ) = %ERROR_SUCCESS
REDIM PRESERVE regs( 1 TO cnt + 1 )
regs( cnt + 1 ) = USING$( "&=&", UCASE$( szClass ), szValue )
INCR cnt
LOOP
ELSE
? using$("Kann REGISTRY & nicht lesen!", regKey),%MB_ICONERROR, "Fehler"
EXIT FUNCTION
END IF
REGCLOSEKEY( hKey )
regKey = "SOFTWARE\ODBC\ODBC.INI\ODBC DATA SOURCES"
lResult = REGOPENKEYEX( %HKEY_LOCAL_MACHINE, regKey, BYVAL 0&, %KEY_ALL_ACCESS, hKey )
IF lResult = %ERROR_SUCCESS THEN
DO WHILE REGENUMVALUE( hKey, dcnt, szClass, %MAX_PATH, dwReserved, %REG_SZ, szValue, %MAX_PATH ) = %ERROR_SUCCESS
REDIM PRESERVE regs( 1 TO cnt + 1 )
regs( cnt + 1 ) = USING$( "&=&", szClass, szValue )
INCR cnt
INCR dcnt
LOOP
ELSE
? USING$( "Kann REGISTRY & nicht lesen!", regKey ), %MB_ICONERROR, "Fehler"
EXIT FUNCTION
END IF
IF dcnt=0 THEN EXIT FUNCTION
REGCLOSEKEY( hKey )
sDB = create_dbstring( regs( ), TRIM$( sText ))
SQL_ERRORCLEARALL
SQL_OPENDATABASE( 2, sDB, %PROMPT_TYPE_NOPROMPT )
IF SQL_ERRORPENDING THEN
SQL_MSGBOX SQL_ERRORQUICKALL+$CRLF+"DSN: "+sDB, %MSGBOX_OK
EXIT FUNCTION
END IF
TableCnt = SQL_TABLECOUNT( 2 )
COMBOBOX RESET CBHNDL, %IDC_DBTABLE
FOR cnt = 1 TO TableCnt
COMBOBOX ADD CBHNDL, %IDC_DBTABLE, SQL_TABLEINFOSTR( 2, cnt, %TABLE_NAME )
NEXT
SQL_CLOSEDATABASE( 2 )
END IF
rgds
WernerLast edited by Werner Bleckwendt; 18 Apr 2008, 01:44 AM.Tags: None
Leave a comment: