How to set the device's clock. WM5.0

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all,

I would like to get the server's time by invoking the web service to reset
the device's clock when my program starts. I use vb.net to code the program.
But I don't know how to set the device's clock.

Please help me. Thanks in advance.

Regards,
Alan
 
You need to P/Invoke SetSystemTime, which also requires you to define the
SYSTEMTIME struct.

Private Structure SYSTETIME
Public uYear As Short
Public uMonth As Short
Public uDayOfWeek As Short
Public uDay As Short
Public uHour As Short
Public uMinute As Short
Public uSecond As Short
Public uMilliseconds As Short
End Structure

<DllImport("Coredll.dll")> _
Private Function SetSystemTime(ByRef st As SYSTEMTIME) As Boolean
End Function

Set the SYSTEMTIME members from your DateTime instance, then call

SetSystemTime(st)

Alternatively use an existing implementation in the SDF -
OpenNETCF.Win32.DateTime2.SetSystemTime(dt)

Peter
 
So, you have two responses, both of which are right. SetLocalTime() sets
the current local computer time, while SetSystemTime() sets the current
time, but in GMT. So, depending on whether the Web service returns the
local time on your device or GMT, you can call either function.

Paul T.
 
Back
Top