生成网站页面的截图

思路 cmd 调用GUI截图工具

代码如下

 public string ExeCommand(string commandText)
    {
        Process p = new Process();
        p.StartInfo.FileName = "cmd.exe";
        p.StartInfo.UseShellExecute = false;
        p.StartInfo.RedirectStandardInput = true;
        p.StartInfo.RedirectStandardOutput = true;
        p.StartInfo.RedirectStandardError = true;
        p.StartInfo.CreateNoWindow = true;
        string strOutput = null;
        try
        {
            p.Start();
            p.StandardInput.WriteLine(commandText);
            p.StandardInput.WriteLine("exit");
            strOutput = p.StandardOutput.ReadToEnd();
            p.WaitForExit();
            p.Close();
        }
        catch (Exception e)
        {
            strOutput = e.Message;
        }
        return strOutput;
    }

调用 

 ExeCommand("G:" + Environment.NewLine +
                      @"IECapt --url=http://www.qq.com/ --out=localfile.png");

 

GUI截图工具下载(开源免费) 下载地址http://iecapt.sourceforge.net/


 

posted @ 2011-04-08 17:58  微雨杏花村  阅读(274)  评论(0编辑  收藏  举报