使用Win32 API将自定义边框添加到另一个应用程序

时间:2017-06-27 12:11:48

标签: c winapi

我想将自定义边框矩形添加到另一个应用程序窗口,如下所示:

enter image description here

我是通过谷歌浏览来编写此代码但是没有帮助我:

HWND hWndX;
HRGN hRegX;
HDC hdc;
hWndX = FindWindow(NULL, "Untitled - Notepad");
hdc = GetDC(hWndX);

if (hWndX)
{
    hRegX = CreateRectRgn(10, 10, 200, 200);
    SetWindowLong(hWndX, GWL_STYLE, GetWindowLong(hWndX, GWL_STYLE));
    SetWindowPos(hWndX, hWndX, 0, 0, 100, 100, SWP_FRAMECHANGED);
    SetWindowRgn(hWndX, hRegX, true);
}
else
    MessageBox(hWndX, "Cant find the window handle", "Error!", 0);

1 个答案:

答案 0 :(得分:-2)

这种事情/可能/曾经在旧的Win16 / Windows 95时代起作用,但是现在,操作系统保护一个程序不会影响另一个程序。要更改另一个进程的边界,您需要将代码(作为dll)注入另一个进程(假设您具有正确的安全级别)。这不是不可能的,但这不是初学者能够做到的事情。