Java examples for Native OS:Windows
Java wrapper for Windows registry API RegEnumKeyEx()
//package com.java2s; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.prefs.Preferences; public class Main { private static final Preferences systemRoot = Preferences.systemRoot(); private static Method windowsRegEnumKeyEx = null; /**//from w w w . j a va 2 s . c om * Java wrapper for Windows registry API RegEnumKeyEx() * @param hKey The native Handle * @param subKeyIndex Index of sub key * @param maxKeyLength The length of max sub key * @return The name of the sub key */ public static byte[] RegEnumKeyEx(int hKey, int subKeyIndex, int maxKeyLength) { try { return (byte[]) windowsRegEnumKeyEx.invoke(systemRoot, new Object[] { new Integer(hKey), new Integer(subKeyIndex), new Integer(maxKeyLength) }); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InvocationTargetException e) { // TODO Auto-generated catch block e.printStackTrace(); } return new byte[0]; } }