9910

          單飛

             :: 首頁 :: 聯系 :: 聚合  :: 管理
          http://www.trustice.com/java/jnireg/index.shtml registry-3.1.3.zip

          public
           static void setProxy(String ip, int port) {
                  String topKeyName 
          = "HKCU";
                  String keyName 
          = "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings";
                  RegistryKey topKey 
          = Registry.getTopLevelKey(topKeyName);
                  RegistryUtil.setDWordCommand(topKey, keyName, 
          "ProxyEnable""1");
                  RegistryUtil.setStringCommand(topKey, keyName, 
          "ProxyServer", ip + ":" + port);
              }

              
          public static boolean isProxy() {
                  
          try {
                      RegistryKey registryKey 
          = Registry.openSubkey(Registry.HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", RegistryKey.ACCESS_READ);
                      RegistryValue registryValue 
          = registryKey.getValue("ProxyEnable");
                      
          boolean proxyEnable = ((RegDWordValue) registryValue).getData() != 0;

                      System.out.println(
          "IE 是否啟用了代理設置: " + proxyEnable);

                      
          if (proxyEnable) {
                          registryValue 
          = registryKey.getValue("ProxyServer");
                          System.out.println(
          "IE 代理服務器是: " + new String(registryValue.getByteData()));
                          
          return true;
                      }

                  } 
          catch (NoSuchKeyException ne) {
                      ne.printStackTrace();
                  } 
          catch (RegistryException re) {
                      re.printStackTrace();
                  }
                  
          return false;
              }
          posted on 2009-07-08 13:27 單飛 閱讀(262) 評論(0)  編輯  收藏 所屬分類: java
          主站蜘蛛池模板: 岱山县| 武乡县| 隆昌县| 溆浦县| 繁昌县| 新丰县| 湘潭市| 鄂托克前旗| 陵水| 城口县| 华容县| 卢氏县| 当涂县| 宁晋县| 天祝| 临高县| 青岛市| 普兰店市| 安国市| 安阳市| 宝坻区| 广德县| 定安县| 涿鹿县| 阿拉善右旗| 靖边县| 庄河市| 崇仁县| 沅江市| 璧山县| 大方县| 彝良县| 高碑店市| 康平县| 汪清县| 涿鹿县| 宣武区| 南部县| 莲花县| 顺义区| 永胜县|