Thanks to everyone, especially @RLWA32, I solved this problem by signing with a real digital certificate
RegisterPointerInputTarget(hwnd,PT_TOUCH) returns ERROR_ACCESS_DENIED
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?