?? winreg.java
字號:
import java.util.*;
// WinReg對象可以用來獲取和設(shè)置 windows注冊表的鍵值.
public class WinReg{
/**
構(gòu)建一個注冊表鍵對象.
@變量theRoot是 HKEY_CLASSES_ROOT, HKEY_CURRENT_USER,
HKEY_LOCAL_MACHINE, HKEY_USERS, HKEY_CURRENT_CONFIG,
HKEY_DYN_DATA中的一個
@變量 thePath 是注冊表鍵的路徑
*/
public WinReg(int theRoot, String thePath) {
root = theRoot;
path = thePath;
}
/**
把有對象給定的路徑下所有注冊表項的名字列舉出來
@返回一個枚舉型的包含所有項名的量
*/
public Enumeration names() {
return new WinRegNameEnumeration(root, path);
}
// 獲得注冊表鍵值
public native Object getValue(String name);
// 設(shè)置注冊表鍵值
public native void setValue(String name, Object value);
public static final int HKEY_CLASSES_ROOT = 0x80000000;
public static final int HKEY_CURRENT_USER = 0x80000001;
public static final int HKEY_LOCAL_MACHINE = 0x80000002;
public static final int HKEY_USERS = 0x80000003;
public static final int HKEY_CURRENT_CONFIG = 0x80000005;
public static final int HKEY_DYN_DATA = 0x80000006;
private int root;
private String path;
static {
System.loadLibrary("WinReg"); // 載入本地方法
}
}
class WinRegNameEnumeration implements Enumeration
{
WinRegNameEnumeration(int theRoot, String thePath) {
root = theRoot;
path = thePath;
}
public native Object nextElement();
public native boolean hasMoreElements();
private int root;
private String path;
private int index = -1;
private int hkey = 0;
private int maxsize;
private int count;
}
class WinRegException extends RuntimeException{
public WinRegException() {}
public WinRegException(String why) {
super(why);
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -