在java里面实现一个功能,传入一个图片png文件的路径,调用windows的图片查看器打开它,我在网上找到的方法是:
Runtime.getRuntime().exec("rundll32 c:\\Windows\\System32\\shimgvw.dll,ImageView_Fullscreen "+fpath);但是执行的时候没反应, 哪位仁兄姐妹知道原因,是写不对还是根本就不是这种用法?

解决方案 »

  1.   

    我这里可以啊。
    你确定fpath没有问题吗?
    另外你的系统是什么情况啊?
    我的win7 32位 可以啊
      

  2.   

    我在D盘下放了一个png图片,命名abc
    import java.io.IOException;public class test7 { public static void main(String[] args) {
    String fpath="D:\\abc.png";
    try {
    Runtime.getRuntime().exec("rundll32 c:\\Windows\\System32\\shimgvw.dll,ImageView_Fullscreen "+fpath);
    } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    }}
    可以的另外注意一下,windows可能把后缀名给隐藏了,你的图片可能是abc.png.png