110,538
社区成员
发帖
与我相关
我的任务
分享
首先要引用两个系统API
[DllImport("User32.dll", EntryPoint = "FindWindow")]
private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll", EntryPoint = "ShowWindow", CharSet = CharSet.Auto)]
public static extern int ShowWindow(IntPtr hwnd, int nCmdShow);
//----------------------------------------------------------------------------------
OpenFileDialog op = new OpenFileDialog();
if (op.ShowDialog() == DialogResult.OK)
{
using (Process p = new Process())
{
p.StartInfo.FileName = Application.StartupPath + "\\FlashPaper\\FlashPrinter.exe";
p.StartInfo.Arguments = string.Format("{0} -o {1}", op.FileName, op.FileName + ".swf");
p.Start();
p.WaitForExit();
Thread.Sleep(3000);//等待程序启动,否则找不到程序窗口句柄
IntPtr child = FindWindow(null, "Macromedia FlashPaper");//查找标题为Macromedia FlashPaper的窗口句柄
if(child != null)
ShowWindow(child, 0);//设置隐藏
}
}