Windows Hook WNDPROC

Posted on 2008-11-11
Last Modified: 2012-05-05
Hi and sorry for my bad english,
i need to Hook a single form of a process (.exe) and i need to get all windows messages.

I've tyred to wirte a function so that:

    if FHWND <> 0 then begin
      LPID := GetWindowPID(FHWND);
      LProcess := OpenProcess(PROCESS_CREATE_THREAD +
      if LPID <> 0 then begin
        KBHook := SetWindowsHookEx(WH_CALLWNDPROC, @HookProc, LProcess, FHWND);

but my HookProc don't receive any message.
I must write a procedure to get the message like Spy++ on a specified form (Handle).

Thank 2 all
Question by:carmas123
    LVL 13

    Accepted Solution


    Author Comment

    Hi and thanks very much for your solution,
    but this solve my problem partialy.

    I've edited the sample for me, but i've another problem now.
    I want to intercept the message like WM_ACTIVATE or other like WM_USER
    for only one form in a process, but your sample attach the wndproc to
    a threadID and i receive all the message from all form in this thread.

    I attach my sample.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
    Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now