最近开发时遇到PDA访问服务器时要和设置服务器的时间到PDA(C#中修改系统时间可不如C++方便),参考了http://blog.csdn.net/iorikyo/archive/2006/10/01/1314892.aspx的文章后通过下面这个类解决了修改PDA时间的问题。代码如下:
using System;
using System.Runtime.InteropServices;
namespace setlocaltime
{
class Systemtime
{
[DllImport("coredll.dll")]
public static extern bool SetLocalTime(ref SYSTEMTIME Time);
[DllImport("coredll.dll")]
public static extern void GetLocalTime(ref SYSTEMTIME Time);
}
public struct SYSTEMTIME
{
public ushort wYear;
public ushort wMonth;
public ushort wDayOfWeek;
public ushort wDay;
public ushort wHour;
public ushort wMinute;
public ushort wSecond;
public ushort wMilliseconds;