Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 330211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:39:37+00:00 2026-05-12T09:39:37+00:00

I want to build a software test automation software and I’m playing around with

  • 0

I want to build a software test automation software and I’m playing around with Windows Hooks for that.

So I built the following C code. Can anyone tell me how to correct it ?

#include "windows.h"

// the call back function
LRESULT CALLBACK JournalRecordProc(int code, WPARAM wParam, LPARAM lParam)
{

    HHOOK hhk = 0;

    if (code > 0)
    {
        // save Data in File
    }

    if (code < 0)
    {
        // work done: now pass on to the next one that does hooking
        CallNextHookEx(hhk, code, wParam, lParam);
    }

    /*
    if (code == )
    {
        // ESC button pressed -> finished recording
        UnhookWindowsHookEx(hhk);
    }
    */

}

int main()

{
    int iRet = 0;

    HHOOK hHook = 0;

    HINSTANCE hMod = 0;

    HOOKPROC (*hHookProc)(int, WPARAM, LPARAM);

        hHookProc = &JournalRecordProc;

    // type of hook, callback function handle, hinstance [dll ?], 0 for systemwide
    hHook =  SetWindowsHookEx(WH_JOURNALRECORD, hHookProc, hMod, 0);

    return iRet;
}

When I compile this I get the compiler errors:

error C2440: '=': 'LRESULT (__stdcall
*)(int,WPARAM,LPARAM)' kann nicht in 'HOOKPROC (__cdecl
*)(int,WPARAM,LPARAM)' konvertiert werden (could not be converted)

error C2440: 'Funktion': 'HOOKPROC (__cdecl *)(int,WPARAM,LPARAM)' kann nicht in 'HOOKPROC' konvertiert werden (could not be converted)

warning C4024: 'SetWindowsHookExA': Unterschiedliche Typen für formalen und übergebenen Parameter 2
  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T09:39:37+00:00Added an answer on May 12, 2026 at 9:39 am

    There’s no need to declare a separate hHookProc variable – just pass your procedure to SetWindowsHookEx directly:

    hHook = SetWindowsHookEx(WH_JOURNALRECORD, JournalRecordProc, hMod, 0);
    

    You’re also going to need a valid module handle:

    HINSTANCE hMod = GetModuleHandle(NULL);
    

    Having made those edits, and made your JournalRecordProc return a value, it all now compiles and works for me (in that SetWindowsHookEx succeeds, anyway).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to learn how to build robust software that is designed to test
So, the think is i want to build a software who can track the
I want to build a bot that asks someone a few simple questions and
I want to build a site where the user can enter text and format
I want to build something like a network scanner, so that I see in
We build software running on Linux servers (Centos) We don't want the customer to
We want to build into our software the capability to build SQL queries freehand
I've completed my windows project in C# and I want to build a nice
I want to use a temp directory that will be unique to this build.
I want to build a lightweight linux configuration to use for development. The first

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.