先用VS2010 or VS2008 提供Spy++找到这个窗口句柄
例如找到为0x00070906
然后调用如下代码
可以放在wpf的启动函数中.
namespace WpfApplication5
{
/// <summary>
/// App.xaml 的交互逻辑
/// </summary>
public partial class App : Application
{
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
public static extern bool IsWindowEnabled(IntPtr hWnd);
[DllImport("user32.dll")]
public static extern IntPtr FindWindow(String sClassName, String sAppName);
[DllImport("user32.dll")]
public static extern bool EnableWindow(IntPtr hwnd, bool bEnable);
private void Application_Startup(object sender, StartupEventArgs e)
{
IntPtr ParenthWnd = new IntPtr(0x00070906);
EnableWindow(ParenthWnd, true);
}
}
}
本文介绍如何使用C#通过P/Invoke调用Windows API函数FindWindow和EnableWindow来获取并启用一个特定窗口。示例代码展示了如何在WPF应用程序启动时启用句柄为0x00070906的窗口。
2867

被折叠的 条评论
为什么被折叠?



