Click here to Skip to main content
15,884,933 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to call the GetPointerFrameInfo function to get the pointer count but the function seems to fail with Error 5 (Access Denied).
Any idea why that is happening and how I can resolve it?
I am trying to call the same inside the hook procedure GetMsgProc as mentioned in the 'What have you tried' section below:

What I have tried:

LRESULT WINAPI GetMsgProc(int nCode, WPARAM wParam, LPARAM lParam)
{
    LPMSG lpMsg = (LPMSG)lParam;
    UINT32 pointerId = GET_POINTERID_WPARAM(lpMsg->wParam);
    switch (lpMsg->message)
    {
    case WM_POINTERUPDATE:
        UINT32 pointerCount = 32;
        POINTER_INFO pointerFrameInfo[32];
        TCHAR outputLogTouchTst[100];

        if (GetPointerFrameInfo(pointerId, &pointerCount, pointerFrameInfo) == 0)
        {
            _stprintf(outputLogTouchTst, _T("Hook: The error code for proc is %d"), GetLastError());
            OutputDebugString(outputLogTouchTst);
            return CallNextHookEx(NULL, nCode, wParam, lParam);
        }

        _stprintf(outputLogTouchTst, _T("Hook: The count of pointers is %d"), pointerCount);
        OutputDebugString(outputLogTouchTst);
        return CallNextHookEx(NULL, nCode, wParam, lParam);
    }
    return CallNextHookEx(getmsghook, nCode, wParam, lParam);
}
Posted
Updated 27-Mar-18 3:04am

1 solution

Access denied is often the cause when the call needs elevated right. Try to run the code with administrator rights.

The same error is typical when the pointer is from another thread.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900