public TreeMap < String , Object > getValues ( ) { int dwIndex , result ; char [ ] lpValueName ; byte [ ] lpData ; IntByReference lpcchValueName , lpType , lpcbData ; String name ; TreeMap < String , Object > values = new TreeMap <> ( String . CASE_INSENSITIVE_ORDER ) ; lpValueName = new char [ 16384 ] ; lpcchValueName = new IntByReference ( 16384 ) ; lpType = new IntByReference ( ) ; lpData = new byte [ 1 ] ; lpcbData = new IntByReference ( ) ; lpcbData . setValue ( 0 ) ; dwIndex = 0 ; OUTER : while ( true ) { result = Advapi32 . INSTANCE . RegEnumValue ( handle , dwIndex , lpValueName , lpcchValueName , null , lpType , lpData , lpcbData ) ; switch ( result ) { case WINERROR . ERROR_NO_MORE_ITEMS : return values ; case WINERROR . ERROR_MORE_DATA : lpData = new byte [ lpcbData . getValue ( ) ] ; lpcchValueName = new IntByReference ( 16384 ) ; continue OUTER ; case WINERROR . ERROR_SUCCESS : name = new String ( lpValueName , 0 , lpcchValueName . getValue ( ) ) ; switch ( lpType . getValue ( ) ) { case WINNT . REG_SZ : values . put ( name , convertBufferToString ( lpData ) ) ; break ; case WINNT . REG_DWORD : values . put ( name , convertBufferToInt ( lpData ) ) ; break ; default : break ; // not supported yet } break ; default : check ( result ) ; } dwIndex ++ ; lpcbData . setValue ( 0 ) ; } }
Get all values under a key .