写这篇博客的目的,就是防止忘记找不到。
实际项目中使用,测试有效。
调用:
IntPtr CurrentAppHandle = GetForegroundWindow();
HandleRef ParentHandle = new HandleRef(this, CurrentAppHandle);
// 初始化窗口风格
IntPtr Style = GetWindowLongPtr(CurrentAppHandle, GWL_STYLE);
uint tempStyle = (uint)Style.ToInt32() & ~WS_CAPTION & ~WS_SYSMENU & ~WS_SIZEBOX;
WinAPI.SetWindowLongPtr(ParentHandle, GWL_STYLE, new IntPtr(tempStyle));
WindowsAPI:
/// <summary>
/// 检索有关指定窗口的信息。该函数还将以指定的偏移量将值检索到额外的窗口内存中。
/// </summary>
/// <param name="hWnd"></param>
/// <param name="nIndex"></param>
/// <returns></returns>
public static IntPtr GetWindowLongPtr(IntPtr hWnd, int nIndex)
{
if (IntPtr.Size == 8)
return GetWindowLongPtr64(hWnd, nIndex);
else
return GetWindo