我正在使用 SetWindowText 函数重命名窗口标题,它似乎可以与“记事本”之类的 Windows 程序一起使用,但是在尝试使用其他 3rd 方程序时它不起作用。我正在通过 Process..MainWindowHandle 获取窗口句柄。我想生成 firefox 并重命名它的窗口标题这是我的要求。进程正在启动,但窗口标题重命名没有发生我得到“发送错误报告”对话框窗口。请帮帮我。下面是代码。
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)
}
}