2

I am trying to register my C# WPF window for pointer input, so that all the touch input is redirected to it, but the RegisterPointerInputTarget is returning false on being passed the target window handle. My code is as follows

//declarations

namespace WpfApplication1
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        IntPtr hWnd;
        int abc;
        public MainWindow()
        {

            InitializeComponent();
            System.Windows.Interop.WindowInteropHelper windowHwnd = new System.Windows.Interop.WindowInteropHelper(this);
            hWnd = windowHwnd.EnsureHandle();
            hWnd = windowHwnd.Handle;
            Minimize.Enable(this);
            this.abc = IWrapper.Rpit(hWnd);
        }
        internal class IWrapper
        {
            const string SHADOW_DLL_NAME = "RPIT_TEST.dll";

            [DllImport(SHADOW_DLL_NAME)]
            public static extern int Rpit(IntPtr hwnd);
        }

    }
}

And the RegisterPointerInputTarget function is defined in the RPIT_TEST.dll (as its a c++ function) as follows:

extern "C" int __declspec (dllexport) __stdcall Rpit(HWND hwnd)
        {
                typedef enum tagPOINTER_INPUT_TYPE { 
                PT_POINTER  = 0x00000001,
            PT_TOUCH    = 0x00000002,
            PT_PEN      = 0x00000003,
            PT_MOUSE    = 0x00000004
            } POINTER_INPUT_TYPE;
            return RegisterPointerInputTarget(hwnd,PT_POINTER);
        }

I have searched a lot for possible errors Any help will be appreciated

4

1 回答 1

1

You have to sign you application and set the uiAccess flag to true in your manifest file.

 <requestedExecutionLevel level="requireAdministrator" uiAccess="true" />

You can also read more about it here. http://msdn.microsoft.com/en-us/library/windows/desktop/ee671610(v=vs.85).aspx

于 2013-09-19T12:37:12.787 回答