用C#来设置系统时间?

JWhiteHorse 2002-01-09 09:56:31
...全文
106 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
nn18 2002-01-09
  • 打赏
  • 举报
回复
http://www.csdn.net/expert/Topic/378/378297.shtm
Jneu 2002-01-09
  • 打赏
  • 举报
回复
using System.Runtime .InteropServices ;
[ StructLayout( LayoutKind.Sequential )]
public class SystemTime
{
public ushort year;
public ushort month;
public ushort dayOfWeek;
public ushort day;
public ushort hour;
public ushort minute;
public ushort second;
public ushort milliseconds;

}

class MainClass
{
[ DllImport( "Kernel32.dll" )]
public static extern void GetSystemTime( [In,Out] SystemTime st );

[ DllImport( "Kernel32.dll" )]
public static extern bool SetSystemTime( [In,Out] SystemTime st );
public static void Main(string[] args)
{

SystemTime st=new SystemTime ();

GetSystemTime(st);

st.year +=1;
bool result=SetSystemTime(st);
}
}
JWhiteHorse 2002-01-09
  • 打赏
  • 举报
回复
Help!

111,097

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧