如何修改系统时间!

baichuan168 2002-09-30 12:21:02
我的代码如下:
SYSTEMTIME *SLT = new SYSTEMTIME;
SLT->wYear = (unsigned short)StrToInt(EditYear->Text);
SLT->wMonth = (unsigned short)StrToInt(EditMonth->Text);
SLT->wDay = (unsigned short)StrToInt(EditDay->Text);
SLT->wHour = (unsigned short)StrToInt(EditHour->Text);
SLT->wMinute = (unsigned short)StrToInt(EditMinute->Text);
SLT->wSecond = (unsigned short)StrToInt(EditSecond->Text);
SetLocalTime(SLT);
执行后,没有问题,可系统时间并没有被修改!
...全文
202 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
NowCan 2002-09-30
  • 打赏
  • 举报
回复
Ohh,WinNT下注意权限问题。
yangguo_god 2002-09-30
  • 打赏
  • 举报
回复
mark
大大怪老张 2002-09-30
  • 打赏
  • 举报
回复
楼上的可以。


或者试一下 SetSystemTime()
hbxtx 2002-09-30
  • 打赏
  • 举报
回复
#include "dos.h"

struct time t; //定义一个时间类型的变量t
t.ti_hour=12;//设置时间为12点
t.ti_min=12;//12分
t.ti_sec=12; //12秒
t.ti_hund=60;//60毫秒
settime(&t); //设置系统时间
baichuan168 2002-09-30
  • 打赏
  • 举报
回复
to shally5(我在一旁静静的看着你):
如果我只修改年月日,不该时分秒,怎么办。我试过把后面的删掉,可是修改不成功!
shally5 2002-09-30
  • 打赏
  • 举报
回复
将String转为char是用
字串名.c_str();
shally5 2002-09-30
  • 打赏
  • 举报
回复
这样可以的
#include <mmsystem.h>

SYSTEMTIME *MyTime=new SYSTEMTIME;
MyTime->wYear=2001;
MyTime->wMonth=12;
MyTime->wDay =21;
MyTime->wHour =23;
MyTime->wMinute =1;
MyTime->wSecond=1;
SetLocalTime(MyTime);
// SetSystemTime(MyTime);
Sleep(1000);
delete MyTime;
baichuan168 2002-09-30
  • 打赏
  • 举报
回复
我还需要修改年月日,怎么把string转换成char

13,873

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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