package JNIRegistry;
import com.ice.jni.registry.RegStringValue;
import com.ice.jni.registry.Registry;
import com.ice.jni.registry.RegistryException;
import com.ice.jni.registry.RegistryKey;
public class CheckDefaultBrowserImpl implements ICheckDefaultBrowser{
public String getDefaultBorserPath() {
try {
Registry registry = new Registry();
registry.debugLevel=true;
RegistryKey regkey = Registry.HKEY_CLASSES_ROOT;
RegistryKey key =registry.openSubkey(regkey,"http\\shell\\open\\command",RegistryKey.ACCESS_ALL);
RegStringValue stringValue = (RegStringValue)key.getValue("");
return stringValue.getData();
}
catch(RegistryException ex) {
ex.printStackTrace();
return null;
}
}
public String getDefaultBrowserName() {
// TODO Auto-generated method stub
try {
Registry registry = new Registry();
registry.debugLevel=true;
RegistryKey regkey = Registry.HKEY_CLASSES_ROOT;
RegistryKey key =registry.openSubkey(regkey,"http\\shell\\open\\ddeexec\\Application",RegistryKey.ACCESS_ALL);
//I suppose there is a javaci value at Software\\Microsoft\\CurrentVersion\\Explorer\\Advanced
// RegStringValue stringValue = new RegStringValue(key,"b",RegistryValue.REG_SZ);
RegStringValue stringValue = (RegStringValue)key.getValue("");
System.out.println(stringValue.getData());
return stringValue.getData();
}
catch(RegistryException ex) {
ex.printStackTrace();
return null;
}
}
public void setDefaultBorwserName(String name) {
try {
Registry registry = new Registry();
registry.debugLevel=true;
RegistryKey regkey = Registry.HKEY_CLASSES_ROOT;
RegistryKey key =registry.openSubkey(regkey,"http\\shell\\open\\ddeexec\\Application",RegistryKey.ACCESS_ALL);
//I suppose there is a javaci value at Software\\Microsoft\\CurrentVersion\\Explorer\\Advanced
// RegStringValue stringValue = new RegStringValue(key,"b",RegistryValue.REG_SZ);
RegStringValue stringValue = (RegStringValue)key.getValue("");
stringValue.setData(name);
key.setValue(stringValue);
}
catch(RegistryException ex) {
ex.printStackTrace();
}
}
public void setDefaultBrowserPath(String path) {
try {
Registry registry = new Registry();
registry.debugLevel=true;
RegistryKey regkey = Registry.HKEY_CLASSES_ROOT;
RegistryKey key =registry.openSubkey(regkey,"http\\shell\\open\\command",RegistryKey.ACCESS_ALL);
//I suppose there is a javaci value at Software\\Microsoft\\CurrentVersion\\Explorer\\Advanced
// RegStringValue stringValue = new RegStringValue(key,"b",RegistryValue.REG_SZ);
RegStringValue stringValue = (RegStringValue)key.getValue("");
stringValue.setData("\""+path+"\"");
System.out.println(stringValue.getData());
key.setValue(stringValue);
}
catch(RegistryException ex) {
ex.printStackTrace();
}
}
}