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 單飛 閱讀(263) 評論(0)  編輯  收藏 所屬分類: java
          主站蜘蛛池模板: 石泉县| 寿阳县| 阳朔县| 瑞昌市| 怀安县| 金门县| 宁陵县| 黔东| 大港区| 开原市| 南汇区| 玉龙| 靖西县| 庆安县| 仁寿县| 涪陵区| 太湖县| 三亚市| 东台市| 昌吉市| 赤壁市| 财经| 福贡县| 白山市| 郯城县| 宽甸| 睢宁县| 涟源市| 隆昌县| 历史| 平阳县| 华安县| 上犹县| 涟源市| 册亨县| 双桥区| 华容县| 进贤县| 永济市| 克拉玛依市| 兰州市|