RegisterPointerInputTarget(hwnd,PT_TOUCH) returns ERROR_ACCESS_DENIED

1 1 0 Reputation points
2025-03-17T08:33:11.0766667+00:00

RegisterPointerInputTarget(hwnd,PT_TOUCH) returns ERROR_ACCESS_DENIED,Here is my C++ code:

int APIENTRY wWinMain(In HINSTANCE hInstance,

                     In_opt HINSTANCE hPrevInstance,

                     In LPWSTR    lpCmdLine,

                     In int       nCmdShow)

{

    UNREFERENCED_PARAMETER(hPrevInstance);

    UNREFERENCED_PARAMETER(lpCmdLine);

    LoadStringW(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);

    LoadStringW(hInstance, IDC_MY111, szWindowClass, MAX_LOADSTRING);

    MyRegisterClass(hInstance);

    if (!InitInstance (hInstance, nCmdShow))

    {

        return FALSE;

    }

    DWORD dwError = 0;

    if (!RegisterPointerInputTarget(g_hwnd, PT_TOUCHPAD))

    {

        dwError = GetLastError();

    }

    HACCEL hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_MY111));

    MSG msg;

    while (GetMessage(&msg, nullptr, 0, 0))

    {

        if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))

        {

            TranslateMessage(&msg);

            DispatchMessage(&msg);

        }

    }

    return (int) msg.wParam;

}

I compiled the program with /MANIFESTUAC:"level='highestAvailable' uiAccess='true'", then signed the program with a Windows trusted root certificate, and put the program in the Program Files folder, but after running it, this function keeps returning ERROR_ACCESS_DENIED. My system is Windows 11 Home Chinese Edition 23H2. How can I make RegisterPointerInputTarget return successfully?

Windows development | Windows API - Win32
{count} votes

1 answer

Sort by: Most helpful
  1. 1 1 0 Reputation points
    2025-03-18T03:18:24.37+00:00

    Thanks to everyone, especially @RLWA32, I solved this problem by signing with a real digital certificate


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.