[Solved] How can I manage windows of applications opened using Win32 API (Notepad, Word, Outlook, Chrome etc.)


The answer is you cannot replace the window procedure cross-process with SetWindowLongPtr and
SetClassLongPtr .

Calling SetWindowLongPtr with the GWLP_WNDPROC index creates a
subclass of the window class
used to create the window. An
application can subclass a system class, but should not subclass a
window class created by another process
.

Calling SetClassLongPtr with the GCLP_WNDPROC index creates a
subclass of the window class
that affects all windows subsequently
created with the class. An application can subclass a system class,
but should not subclass a window class created by another process.

In addition, the hwnd parameter of SetWindowLongPtr also has UIPI restrictions:

The SetWindowLongPtr function fails if the process that owns the
window specified by the hWnd parameter is at a higher process
privilege in the UIPI hierarchy than the process the calling thread
resides in.

Windows XP/2000: The SetWindowLongPtr function fails if the window
specified by the hWnd parameter does not belong to the same process as
the calling thread.

It is recommended to use SetWindowsHookEx, if you want to monitor window messages.
You could read this document: Using Hooks

You could also create your own window, with the same WNDCLASSEX(GetClassLongPtr from the target window) and style(GetWindowLongPtr from the target window).

Or you’ve already known what you are doing, try dll injection.

solved How can I manage windows of applications opened using Win32 API (Notepad, Word, Outlook, Chrome etc.)