gpt4 book ai didi

c# - 使用 C# 关闭个性化窗口

转载 作者:可可西里 更新时间:2023-11-01 11:49:21 26 4
gpt4 key购买 nike

我编写了一个更改 Windows 主题的程序,但在更改主题后个性化窗口仍然打开,我想将其关闭。我尝试使用 process.kill() 和熟悉的进程名称,但它没有用。谢谢。

我正在做的代码如下:

ProcessStartInfo theinfo = new ProcessStartInfo(themepath + "aero.theme");
theinfo.CreateNoWindow = true;
Process thepr = new Process();
thepr.StartInfo = theinfo;
thepr.Start();

其中“themepath”是 aero.theme 的字符串位置。我什至将 CreateNoWindow 启用为 true 然后它也打开个性化以更改主题但没有自动关闭它。

最佳答案

首先使用查找窗口通过使用 FindWindow.. 从它们的名称中获取窗口

 [DllImport("user32.dll")]
public static extern int FindWindow(string lpClassName,string lpWindowName);

它返回你想要的窗口句柄,现在你可以使用发送消息来关闭它..

 [DllImport("User32.dll")]
public static extern int SendMessage(int hWnd, uint Msg, int wParam, int lParam);
public const int WM_SYSCOMMAND = 0x0112;
public const int SC_CLOSE = 0xF060;
private void closeWindow()
{
// retrieve the handler of the window
int iHandle = FindWindow("CabinetWClass", "Personalization");
if (iHandle > 0)
{
SendMessage(iHandle, WM_SYSCOMMAND, SC_CLOSE, 0);
}
}

关于c# - 使用 C# 关闭个性化窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34094505/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com