java获取默认邮件程序的名称

时间:2014-09-25 15:32:25

标签: java

是否可以使用(thunderbird,outlook等)获取默认邮件客户端的名称? desktop.mail()打开默认邮件客户端。但是java在哪里读取哪个是默认的邮件客户端?

此致

1 个答案:

答案 0 :(得分:0)

SOLVE。

我可以获取默认邮件客户端的注册表值:

   package side_pakets;

import java.io.IOException;
import java.io.InputStream;
import java.io.StringWriter;

public class Read_Win_Registry
{
    String output;
    String input;
    String location = "HKEY_CURRENT_USER\\Software\\Clients\\Mail";
    /**
     * 
     * @param location
     *            path in the registry
     * @param /ve returns default registry values
     * 
     */
    public String readRegistry(String location)
    {
        try
        {
            Process process = Runtime.getRuntime().exec(
                    "reg query " + location + " /ve ");

            StreamReader reader = new StreamReader(process.getInputStream());
            reader.start();
            process.waitFor();
            reader.join();
            output = reader.getResult();

        } catch (Exception e)
        {
            // return null;
        }
        return output;

    }

    static class StreamReader extends Thread
    {
        private InputStream is;
        private StringWriter sw = new StringWriter();

        public StreamReader(InputStream is)
        {
            this.is = is;
        }

        public void run()
        {
            try
            {
                int c;
                while ((c = is.read()) != -1)
                    sw.write(c);
            } catch (IOException e)
            {
            }
        }
    }

}