我使用SetWindowText函數功能重新命名它似乎與Windows程序,如「記事本」工作的窗口標題,但通過其他第三方程序它不是working.I我抓住窗口句柄嘗試時Process..MainWindowHandle。我想產卵Firefox和重命名它的窗口標題,這是我的要求。進程正在啓動,但窗口標題重命名沒有發生我收到「發送錯誤報告」對話窗口。請幫我out.Below是代碼。無法重命名窗口標題文本通過SetWindowText函數功能
using System;
using Microsoft.Win32;
using System.Runtime.InteropServices;
using System.Threading;
using System.Diagnostics;
namespace SampleNamespace
{
public class SampleClass
{
[DllImport("user32.dll")]
static extern int SetWindowText(IntPtr hWnd, string text);
public static void Main()
{
Process p = Process.Start("C:\\Sham\\pg\\Firefox\\firefox.exe");
Thread.Sleep(1000);
SetWindowText(p.MainWindowHandle, "FireFox via Process-Start");
} // End of Main function (program statup)
}
}
你說的「它不工作」是什麼意思?你得到一個錯誤,或窗口文本沒有改變?您很可能會更改與主瀏覽器UI不同的窗口,因此您的新標題未能反映在您希望看到的位置。 – 2011-03-02 11:27:15
我得到一個錯誤(發送報告對話窗口)窗口文本也沒有改變。我想要的是改變通過Process.Start生成的窗口的窗口標題。我可以做那個..? – user641057 2011-03-03 09:47:38