Hello Smyle, You may try the given code snippet. Let's say we are changing the time on a button click: BEGIN CODE Imports System.Runtime.InteropServicesPublic Class Form1 'System time structure used to pass to P/Invoke...<StructLayoutAttribute(LayoutKind.Sequential)> _ Private Structure SYSTEMTIME Public year As ShortPublic month As ShortPublic dayOfWeek As ShortPublic day As ShortPublic hour As ShortPublic minute As ShortPublic second As ShortPublic milliseconds As ShortEnd Structure'P/Invoke dec for setting the system time...<DllImport( "Kernel32.dll")> _Private Shared Function SetLocalTime(ByRef time As SYSTEMTIME) As BooleanEnd FunctionPublic Function SetDeviceTime(ByVal p_NewDate As Date) 'Populate structure...'Substitute <YOUR DATE OBJECT> with your date object returned via GPRS...Dim st As SYSTEMTIMEst.year = p_NewDate.Year st.month = p_NewDate.Month st.dayOfWeek = p_NewDate.DayOfWeek st.day = p_NewDate.Day st.hour = p_NewDate.Hour st.minute = p_NewDate.Minute st.second = p_NewDate.Second st.milliseconds = p_NewDate.Millisecond 'Set the new time...SetLocalTime(st) End FunctionPrivate Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.ClickSetDeviceTime( "01/01/2009")End SubEnd Class END CODE
I hope this will help. Regards, Allen Smith
Allen Smith
Software Engineer
ComponentOne LLC
www.componentone.com
|