Get the WNDPROC for windows handle
Exist any Windows api function to retrieve the WNDPROC for a Windows Handle?
Thanks in advance.
Use GetWindowLongPtr(hwnd, GWLP_WNDPROC).
Caution: GetWindowLongPtr is actually #defined to GetWindowLong for 32-bit systems, so in order to import it in Delphi you might need to use GetWindowLong instead. As well, GetWindowLongPtr itself is #defined to either GetWindowLongPtrA or GetWindowLongPtrW (for non-unicode and unicode targets), so again you might need to choose the right name manually for Delphi if the import system there is not really smart.
Remember that if you are going to call the obtained window proc, you should do it using CallWindowProc. Thanks to @In silico for the hint.
Please note that the value which is returned is not always the real pointer to the window procedure. Sometimes it's just a kind of handle which is recognized and correctly processed by CallWindowProc. For example, you'll not get the real function pointer if your application is ANSI, but the window belongs to a Unicode component (or vice versa). See this posting in The Old New Thing for more details.