2013-09-16 64 views
2

我嘗試註冊我的指針輸入C#WPF窗口,讓所有的觸摸輸入被重定向到它,但RegisterPointerInputTarget正在恢復對正在傳遞的目標窗口句柄假。 我的代碼如下RegisterPointerInputTarget()函數提供虛假

//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); 
     } 

    } 
} 

而且RegisterPointerInputTarget功能在RPIT_TEST.dll定義(作爲一個C++函數)如下:

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); 
     } 

我尋覓了很多可能存在的錯誤 任何幫助將不勝感激

回答

1

您必須簽署您的應用程序和設置uiAccess標誌設置爲true在manifest文件。

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

您也可以在這裏閱讀更多。 http://msdn.microsoft.com/en-us/library/windows/desktop/ee671610(v=vs.85).aspx

+0

我試圖調試我的uiAccess的項目設置爲true,我得到類似這樣的錯誤, http://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/7a42efab-5ce8-456f- 8a58-dfedbc2cefcb/debugging-with-uiaccesstrue 你知道如何克服這個問題嗎? –

+0

更新:我跟着步驟從這裏, http://stackoverflow.com/questions/12192504/debugging-with-visual-studio-2012-windows-8-and-user-account-control ,似乎執行,但函數仍然返回false:/ –