The sample code below will check to see if the ceSetTime.exe is already on the device, if not it will push it to the device. Then the time and date from the desktop is used as parameters when starting the ceSetTime app on the device. One problem with this approach is the security prompt from Windows Mobile 5.0.
VB 6.0 Sample Code
' Check to see if ceSetTime.exe utility is on the device
If Not SregoCETPx1.VerifyFile("\windows\ceSetTime.exe") Then
' if ceSetTime.exe exe is not on the device, then copy it to the device
' The ceSetTime.exe should be in the same path as the main app in this
' example; however, it could be anywhere as long as you know the location
If Not SregoCETPx1.PushFile(App.Path + "\ceSetTime.exe", _
"\windows", False) Then
Debug.Print "unable to copy utility to device"
' Build the command line for the ceSetTime.exe utility
' the argument will be a valid integer value or and asterisk (*) to
' keep the devices original setting
Dim timeStr As String
timeStr = Str(Year(Date)) + " " + Str(Month(Date)) + " " + _
Str(Day(Date)) + " " + _
Str(Hour(Time)) + " " + Str(0) + " " + Str(Second(Time))
' Run the ceSetTime.exe on the device with the
' desktop's time as a parameter
SregoCETPx1.StartApplicationEx "\windows\ceSetTime.exe", timeStr
' Delete ceSetTime.exe from device
SregoCETPx1.DeleteFile App.Path + "\ceSetTime.exe"