How do I look up the value of something in the Microsoft Windows Registry?

John Zukowski

There is no pure Java way to do this. If you don't mind locking yourself into Microsoft's VM, the following program demonstrates.

import com.ms.wfc.app.*;
public class ODBCSource {
  public static void main(String args[]) {
    RegistryKey regKey =
        ("SoftwareODBCODBC.INIODBC Data Sources");
    if (regKey != null) {
      String dsn[] = regKey.getValueNames();
      for(int i = 0;  i < dsn.length; i++) { 
        System.out.println("Name: " + dsn[i]);
        System.out.println("  Value: " + regKey.getValue(dsn[i]));
0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.