Here's the code to call the CerunAppAtEvent in VB .NET !
Add 2 buttons in a form (1 for activate, 1 for deactivate: one call the Activate Method and the other the Deactivate Method)
Code:
Public Class ExecEvent
<System.Runtime.InteropServices.DllImport("coredll.dll")> _
Private Shared Function CeRunAppAtEvent(ByVal AppName As String, ByVal WhichEvent As Integer) As Boolean
End Function
Const NOTIFICATION_EVENT_NONE = 0
Const NOTIFICATION_EVENT_TIME_CHANGE = 1
Const NOTIFICATION_EVENT_SYNC_END = 2
Const NOTIFICATION_EVENT_DEVICE_CHANGE = 7
Const NOTIFICATION_EVENT_RS232_DETECTED = 9
Const NOTIFICATION_EVENT_RESTORE_END = 10
Const NOTIFICATION_EVENT_WAKEUP = 11 'PocketPC only
Const NOTIFICATION_EVENT_TZ_CHANGE = 12 'PocketPC only
Private Shared bRet As Boolean
Private Shared AppPath As String = "\windows\calc.exe"
Public Shared Sub Activate()
Try
bRet = CeRunAppAtEvent(AppPath, NOTIFICATION_EVENT_SYNC_END)
Catch
MessageBox.Show(Err.Description)
End Try
End Sub
Public Shared Sub Deactivate()
Try
bRet = CeRunAppAtEvent(AppPath, _
NOTIFICATION_EVENT_NONE)
Catch
MessageBox.Show(Err.Description)
End Try
End Sub
End Class
Bookmarks