zwMan_hz 发表于 2013-2-7 03:57:16

Java 判断本地有没有安装word

import java.io.File;   import ca.beq.util.win32.registry.RegistryKey;   import ca.beq.util.win32.registry.RootKey;   public class test {         /**       * @param args       */      public static void main(String[] args) {         // TODO Auto-generated method stub         RegistryKey r = new RegistryKey(RootKey.HKEY_CURRENT_USER,"Software\\Microsoft\\Office\\11.0\\Word\\Options");            String path = r.getValue("PROGRAMDIR").getStringValue();         if(path!=null){               if (new File(path + "WINWORD.EXE").isFile())               {                   System.out.println("安装过word");               }else{                   System.out.println("没安装过word");               }         }else{            System.out.println("没安装过word");         }       }   } 
 
需要用到jRegistryKey.jar,下载链接http://nchc.dl.sourceforge.net/project/jregistrykey/binaries/1.4.0/jRegistryKey-bin-1.4.0.zip
 
<div class="solution">补充:
dll需要拷贝到C:\WINDOWS\system32下
页: [1]
查看完整版本: Java 判断本地有没有安装word