禁用Windows Mobile任务栏,但启用摄像头

时间:2012-03-21 15:10:25

标签: .net vb.net windows-mobile camera

我正在编写一个禁用该隐藏的Windows Mobile应用程序并禁用Windows任务栏,从而阻止用户访问Windows功能。但是,应用程序也需要能够拍照,这就是问题的开始。启用任务栏后,设备上的其他按钮(Home,Capture Photo,Up,Down等)也会被禁用。我不知何故必须发送一条启用“捕获照片”按钮的消息,但我的所有尝试都证明没有结果。

我还使用Visual Studio 2008的远程间谍工具来跟踪消息(并获取十六进制值)

这是我到目前为止的代码:

Imports System.Runtime.InteropServices Imports Microsoft.WindowsCE.Forms Imports Microsoft.WindowsMobile.Forms Public Class BarControl <DllImport("coredll.dll", EntryPoint:="GetForegroundWindow", SetLastError:=True)> _ Private Shared Function GetForegroundWindow() As IntPtr End Function <DllImport("aygshell.dll", EntryPoint:="SHFullScreen", SetLastError:=True)> _ Private Shared Function SHFullScreen(ByVal hwndRequester As IntPtr, _ ByVal dwState As Integer) As Boolean End Function <DllImport("coredll.dll", EntryPoint:="EnableWindow")> _ Private Shared Function EnableWindow(ByVal hwnd As IntPtr, _ ByVal bEnable As Boolean) As Boolean End Function <DllImport("coredll.dll", EntryPoint:="FindWindow")> _ Private Shared Function FindWindow(ByVal lpClassName As String, _ ByVal lpWindowName As String) As IntPtr End Function <DllImport("coredll.dll", _ EntryPoint:="GetForegroundWindow", _ SetLastError:=True)> _ Private Shared Function SendMessage(ByVal hWnd As IntPtr, _ ByVal Msg As Integer, _ ByVal wParam As Integer, _ ByVal lParam As Integer) As IntPtr End Function Private Const SHFS_SHOWSTARTICON As Integer = &H10 Private Const SHFS_HIDESTARTICON As Integer = &H20 Private Const SHFS_HIDESIPBUTTON As Integer = &H8 Private Const SHFS_SHOWSIPBUTTON As Integer = &H4 Private Const SHFS_SHOWTASKBAR As Integer = &H1 Private Const SHFS_HIDETASKBAR As Integer = &H2 'Additional variables Private Const WM_ENABLE As Integer = &HA Private Const CAMERA_INDICATOR As Integer = &H800C 'WM_APP+12 Private Const CAMERA_ENABLED As Integer = &H1 Private Const CAMERA_DISABLED As Integer = &H0 Private Const WM_USER As Integer = &H400 Private Const WM_ACTIVATE_CAMERAVIEW As Integer = WM_USER + 1 Private Const WM_CANCELMODE As Integer = &H1F Private Shared Function SetTaskBarEnabled(ByVal bEnabled As Boolean) As Boolean Dim hwnd As IntPtr = FindWindow("HHTaskBar", Nothing) If Not hwnd.Equals(IntPtr.Zero) Then If bEnabled Then Return EnableWindow(hwnd, True) Else Return EnableWindow(hwnd, False) End If End If Return True End Function Private Shared Function SetTaskbarVisible(ByVal visible As Boolean) As Boolean Dim hwnd As IntPtr = FindWindow("HHTaskBar", Nothing) If Not hwnd.Equals(IntPtr.Zero) Then If visible Then Return SHFullScreen(hwnd, SHFS_SHOWTASKBAR) Else Return SHFullScreen(hwnd, SHFS_HIDETASKBAR) End If End If End Function Private Shared Function SetStartButtonVisible(ByVal visible As Boolean) As Boolean Dim hwnd As IntPtr = GetForegroundWindow() If Not hwnd.Equals(IntPtr.Zero) Then If visible Then Return SHFullScreen(hwnd, SHFS_SHOWSTARTICON) Else Return SHFullScreen(hwnd, SHFS_HIDESTARTICON) End If End If End Function Private Shared Function SetSIPVisible(ByVal visible As Boolean) As Boolean Dim hwnd As IntPtr = GetForegroundWindow() If Not hwnd.Equals(IntPtr.Zero) Then If visible Then Return SHFullScreen(hwnd, SHFS_HIDESIPBUTTON) Else Return SHFullScreen(hwnd, SHFS_HIDESIPBUTTON) End If End If End Function Public Shared Sub ShowTaskBar() SetTaskBarEnabled(True) SetTaskbarVisible(True) End Sub Public Shared Sub HideTaskBar() SetTaskbarVisible(False) SetTaskBarEnabled(False) End Sub Public Shared Sub ShowSIP() SetSIPVisible(True) End Sub Public Shared Sub HideSIP() SetSIPVisible(False) End Sub Public Shared Sub HideStartButton() SetStartButtonVisible(False) End Sub Public Shared Sub ShowStartButton() SetStartButtonVisible(True) End Sub Public Sub MySendMessage(ByVal target As String, _ ByVal message As Integer, _ ByVal lParam As Integer, _ ByVal wParam As Integer) Dim hwnd As IntPtr = FindWindow(target, Nothing) Dim msg As Microsoft.WindowsCE.Forms.Message = Microsoft.WindowsCE.Forms.Message.Create(hwnd, message, lParam, wParam) MessageWindow.SendMessage(msg) End Sub 'Enables / Disables the camera Private Sub btnDisableCam_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisableCam.Click MySendMessage("HHTaskBar", WM_ENABLE, 0, CAMERA_INDICATOR) 'EnableWindow(WM_ACTIVATE_CAMERAVIEW, False) 'MySendMessage("HHTaskBar", CAMERA_INDICATOR, WM_ENABLE, CAMERA_DISABLED) 'MySendMessage("HHTaskBar", WM_ACTIVATE_CAMERAVIEW, WM_ENABLE, CAMERA_DISABLED) 'MySendMessage("HHTaskBar", WM_CANCELMODE, 0, 0) End Sub Private Sub btnEnableCam_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEnableCam.Click MySendMessage("HHTaskBar", WM_ENABLE, 1, CAMERA_INDICATOR) 'EnableWindow(WM_ACTIVATE_CAMERAVIEW, True) 'MySendMessage("HHTaskBar", WM_CANCELMODE, 1, 0) 'MySendMessage("HHTaskBar", CAMERA_INDICATOR, WM_ENABLE, CAMERA_ENABLED) End Sub End Class

非常感谢任何帮助!

提前致谢!

伊恩

1 个答案:

答案 0 :(得分:0)

您是否考虑过在需要相机正常工作时重新启用按钮?一旦相机功能完成,再次禁用按钮??

ShowCameraDialog()

  • 启用任务栏按钮
  • 显示相机对话框
  • 对话响应?..用图片做的东西..
  • 再次禁用任务栏按钮