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 單飛 閱讀(265) 評論(0)  編輯  收藏 所屬分類: java
          主站蜘蛛池模板: 客服| 洪泽县| 龙川县| 会理县| 辉县市| 色达县| 清徐县| 昌黎县| 金溪县| 南华县| 神木县| 沅陵县| 新丰县| 如皋市| 密云县| 卓资县| 镇康县| 鹤峰县| 新巴尔虎左旗| 阳曲县| 平昌县| 辽源市| 扶风县| 广德县| 盐池县| 余干县| 绵竹市| 沧州市| 临颍县| 临沧市| 承德市| 明溪县| 建水县| 宁强县| 尉犁县| 定日县| 蒙自县| 泽州县| 读书| 南木林县| 佛学|