C#如何打开应用程序,设置应用程序的显示位置? 本帖最后由 s1t16 于 2010-08-02 17:04:10 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 [System.Runtime.InteropServices.DllImportAttribute("user32.dll", EntryPoint="FindWindow")]public static extern System.IntPtr FindWindow( string lpClassName, string lpWindowName) ;[System.Runtime.InteropServices.DllImportAttribute("user32.dll", EntryPoint="MoveWindow")] public static extern bool MoveWindow( System.IntPtr hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint) ; 你要设置什么?你是不是希望调用exe执行后,那个exe的主窗口显示在制定的位置? reply by 阿捷 调用windform窗口显示flash,设置窗体的位置Position引用AxShockwaveFlashObjects, ShockwaveFlashObjects 谢谢大家了,在这里我写一下,用的是windows APICODE如下声明:[System.Runtime.InteropServices.DllImportAttribute("user32.dll", EntryPoint = "MoveWindow")]public static extern bool MoveWindow(System.IntPtr hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint);调用System.Diagnostics.Process pf = System.Diagnostics.Process.Start(url);pf.WaitForInputIdle();MoveWindow(pf.MainWindowHandle, 100, 10, 300, 200, true);关闭(进程) System.Int16 i; System.String StrNameID; System.Diagnostics.Process[] ShowID = System.Diagnostics.Process.GetProcesses(); for (i = 0; i < ShowID.Length; i++) System.Console.WriteLine(ShowID[i].ProcessName + " " + ShowID[i].Id); System.Threading.Thread.Sleep(200); System.Console.Write("请输入你要关闭的进程名称: "); StrNameID = "欢迎引导窗体"; System.Diagnostics.Process[] CloseID = System.Diagnostics.Process.GetProcessesByName(StrNameID); // if (CloseID.Length != 0) { for (i = 0; i < CloseID.Length; i++) { if (CloseID[i].Responding && !CloseID[i].HasExited) { System.Console.WriteLine("指定进程存在而且正在响应中...正在关闭."); CloseID[i].CloseMainWindow(); if (!CloseID[i].HasExited) { System.Console.WriteLine("由于特别原因无法关闭进程,现在强制关闭!!!"); CloseID[i].Kill(); } } else { System.Console.WriteLine("指定进程存在但无法响应...正在强制关闭!"); CloseID[i].Kill(); } } } else System.Console.WriteLine("指定进程不存在无法关闭!请确认输入正确.");呵呵,终于做出来了,希望对大家有帮助,也谢谢大家对我的帮助! C# lock 关键字 在VC++ 中如何实现的? wcf服务nettcp协议下远程调用出错 请人解释下代码 NET vs2008的msdn 中 怎么没有c++部分呢?? 翻译以逗号隔开的id MSSQL导出TXT问题 我想用C#封装个DLL给JAVA程序调用,应该怎么做? 讨论:在打飞机游戏中如何判断飞机(对象)被子弹(对象)击中? asp:TreeView大数据绑定慢怎么解决? 如何在程序中用资源中图? C#使用HttpWebRequest发起SOAP请求,返回结果中500错误的处理 framework2.0 faulting module mscorwks.dll错误
public static extern System.IntPtr FindWindow( string lpClassName, string lpWindowName) ;[System.Runtime.InteropServices.DllImportAttribute("user32.dll", EntryPoint="MoveWindow")]
public static extern bool MoveWindow( System.IntPtr hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint) ;
引用AxShockwaveFlashObjects, ShockwaveFlashObjects
CODE如下
声明:
[System.Runtime.InteropServices.DllImportAttribute("user32.dll", EntryPoint = "MoveWindow")]
public static extern bool MoveWindow(System.IntPtr hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint);
调用
System.Diagnostics.Process pf = System.Diagnostics.Process.Start(url);
pf.WaitForInputIdle();
MoveWindow(pf.MainWindowHandle, 100, 10, 300, 200, true);
关闭(进程)
System.Int16 i;
System.String StrNameID;
System.Diagnostics.Process[] ShowID = System.Diagnostics.Process.GetProcesses();
for (i = 0; i < ShowID.Length; i++)
System.Console.WriteLine(ShowID[i].ProcessName + " " + ShowID[i].Id);
System.Threading.Thread.Sleep(200);
System.Console.Write("请输入你要关闭的进程名称: ");
StrNameID = "欢迎引导窗体";
System.Diagnostics.Process[] CloseID = System.Diagnostics.Process.GetProcessesByName(StrNameID);
//
if (CloseID.Length != 0)
{
for (i = 0; i < CloseID.Length; i++)
{
if (CloseID[i].Responding && !CloseID[i].HasExited)
{
System.Console.WriteLine("指定进程存在而且正在响应中...正在关闭.");
CloseID[i].CloseMainWindow();
if (!CloseID[i].HasExited)
{
System.Console.WriteLine("由于特别原因无法关闭进程,现在强制关闭!!!");
CloseID[i].Kill();
}
}
else
{
System.Console.WriteLine("指定进程存在但无法响应...正在强制关闭!");
CloseID[i].Kill();
}
}
}
else
System.Console.WriteLine("指定进程不存在无法关闭!请确认输入正确.");
呵呵,终于做出来了,希望对大家有帮助,也谢谢大家对我的帮助!