Change system date and time

pcastell

Member
Joined
Sep 15, 2005
Messages
5
Programming Experience
Beginner
Hello,

Does anybody knows how can be changed the system date and time on a POCKET PC application, from VB.NET ?

Thanks in advance.
 
this class below will change the date and time.....

i'd also like to be able to change the regional settings on the device but dont know how to do this

VB.NET:
Imports System.Runtime.InteropServices

Public Class DeviceDateTime

	Public Sub New()

	End Sub

	'System time structure used to pass to P/Invoke...
	<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

	'P/Invoke dec for setting the system time...
	<DllImport("coredll.dll")> _
	Private Shared Function SetLocalTime(ByRef time As SYSTEMTIME) As Boolean

	End Function

	Public Function SetDeviceTime(ByVal p_NewDate As Date)
		'Populate structure...
		'Substitute <YOUR DATE OBJECT> with your date object returned via GPRS...

		Dim st As SYSTEMTIME
		st.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 Function
End Class
 
It works pretty good. Thank you very much!!

As you can expect, I am also interested to be able to change the regional settings on the device. I'll be on line, and will post any information about.


Pere
 
Hi I get this error message.

Any Idea, I am trying the code in Windows XP

An unhandled exception of type 'System.DllNotFoundException' occurred in ChangeSystemTime.exe

Additional information: Unable to load DLL (coredll.dll).
 
Back
Top