I got handle of Phone window , and hook the window like below:
Private Sub SetHook()
mOldWndProc = SetWindowLong(mhWnd, GWL_WNDPROC,
Marshal.GetFunctionPointerForDelegate(mProc))
End Sub
'Restores the original window procedure for the control.
Private Sub Unhook()
SetWindowLong(mhWnd, GWL_WNDPROC, mOldWndProc)
End Sub
Protected Overridable Function WndProc(
ByVal hwnd As IntPtr, ByVal msg As Integer,
ByVal wParam As Integer, ByVal lParam As Integer) As Integer
If msg = WM_HOTKEY Then
Dim fuModifiers As Int32 = LoWord(lParam)
Dim uVirtKey As Int32 = HiWord(lParam)
Dim isCorrectKey As Boolean = (uVirtKey = VK_TBACK)
If (lParam And &H1000) = 0 Then 'this is key down event
If isCorrectKey Then
Dim e As New KeyPressEventArgs(ChrW(uVirtKey Or fuModifiers))
RaiseEvent OnKeyPress(New Object, e)
End If
Else 'this is keyup event
End If
'return 1 so that OS won't process the key.
'We must return 1 for both KeyUp and KeyDown
If isCorrectKey Then Return 1
End If
'if we are here, the key was unhandled, call the parent handler
Return CallWindowProc(mOldWndProc, hwnd, msg, wParam, lParam)
End Function
After hook, when I click on Phone to open window, it raise error:
A native exception has occurred in Test.exe, Select Quit and restart program. OR The remote connection to the device has been lost. Please verify the device connection and restart debugging.
Please can u help me to fix it.