Display the Date/Time panel from my application

  • Thread starter Thread starter rodeo rider
  • Start date Start date
R

rodeo rider

how can my program get the system Date/Time screen to execute/display in
WinCE 4.2? i need for the user to confirm that their system date/time is
accurate prior to entering data in my application. tia for any direction!
 
ok, i guess people maybe grew tired of answering this same old question.

here is what is working for me. obviously, using the OpenNetCF at present.
'
'
Dim rvb As New OpenNETCF.Diagnostics.Process

rvb.StartInfo.FileName = "\windows\ctlpnl.exe"

rvb.StartInfo.Arguments = "\windows\cplmain.cpl,13"

rvb.StartInfo.UseShellExecute = True

rvb.Start()
 
or, you can allow the user to see and make any necessary adjustments to
your device's local date and time by presenting the user with a form that
contains two datetime pickers (one for the date, one for the time) and some
code
that looks like the code below. this saves you from having to branch out to
the system settings and hope the user returns to your app where you expect
him to.
--
Darren Shaffer
..NET Compact Framework MVP
Principal Architect
Connected Innovation
www.connectedinnovation.com

Imports System.Runtime.InteropServices

Public Class DateTimeCheck

Private _valueChanged As Boolean = False

Public Sub DateTimeCheck()

End Sub

<StructLayoutAttribute(LayoutKind.Sequential)> _
Private Structure SYSTEMTIME
Public year As Short
Public month As Short
Public dayOfWeek As Short
Public day As Short
Public hour As Short
Public minute As Short
Public second As Short
Public milliseconds As Short
End Structure

<DllImport("coredll.dll")> _
Private Shared Function SetLocalTime(ByRef time As SYSTEMTIME) As
Boolean
End Function

Private Sub dtpDeviceDate_ValueChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles dtpDeviceDate.ValueChanged
_valueChanged = True
End Sub

Private Sub dtpDeviceTime_ValueChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles dtpDeviceTime.ValueChanged
_valueChanged = True
End Sub

Private Sub DateTimeCheck_Closing(ByVal sender As System.Object, ByVal e
As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing

If _valueChanged Then

Dim st As SYSTEMTIME = New SYSTEMTIME()
st.month = dtpDeviceDate.Value.Month
st.day = dtpDeviceDate.Value.Day
st.year = dtpDeviceDate.Value.Year
st.hour = dtpDeviceTime.Value.Hour
st.minute = dtpDeviceTime.Value.Minute

Try
If SetLocalTime(st) Then
MessageBox.Show("Device Date and Time Successfully
Updated.", _
"Success", MessageBoxButtons.OK,
MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1)
Else
MessageBox.Show("Device Date and Time Update Failed. Go
to Start-->Settings-->System " & _
"and set your device date and time before continuing.",
_
"Update Failed", MessageBoxButtons.OK,
MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1)
End If
Catch ex As Exception
MessageBox.Show("Device Date and Time Update Failed. Go to
Start --> Settings --> System --> Clock & Alarms" & _
"and set your device's date and time before
continuing.", _
"Update Failed", MessageBoxButtons.OK,
MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1)
End Try

End If

End Sub

End Class
 
Back
Top