想在程序中动态修改windows系统时间
怎么做呢?急!!!
怎么做呢?急!!!
解决方案 »
- 如何把一串字符串中的相同字符串找出来
- 如何调用网上的 ACCESS 数据库?
- 求教: 怎么实现象 用ctrl+alt+z 调出qq窗口那样的功能?
- 服务程序的一个问题!
- 交流:有多少人在用Delphi+SQL Server开发系统,如何架构的?
- 运行时出错的问题?在线等待!!!!!!!!
- 怪现像:ATL做的COM Server, Delphi做的Client.
- 把控件的Dragkind改为dkdoc后,拖曳后出现一个小窗口,点击哪个X后,该控件怎么消失了?
- 100分:关于面试问题!有兴趣的朋友请进!!!
- 如何修改系统单元文件,如何编译,修改一些文件,好象不太行,看不到反映,为什么,如何解决
- 要用delphi开发浏览器,要用拿几个控件,除了用webbrowser之外,还可以用什么呀
- 如何去掉 弹出菜单 自动添加的快捷键和下划线
Y, M, D, H, N, S, MS: Word;
T: TDateTime;
SystemTime: TSystemTime;
begin
Y := 2005;
M := 3;
D := 10;
H := 1;
N := 0;
S := 0;
MS := 0;
T := EncodeDateTime(Y, M, D, H, N, S, MS); // 2005-3-10 1:0:0.0
DateTimeToSystemTime(T, SystemTime);
SetLocalTime(SystemTime);
end;要 uses DateUtils;
DateTime:TDateTime;
begin
DateTime:=StrToDateTime(Edit1.text);
DateTimeToSystemTime(DateTime,systemtime);
SetLocalTime(SystemTime);
GetLocalTime(SystemTime);
DateTime:=SystemTimeToDateTime(SystemTime);
end;
procedure TfrmMain.SetTimeFormat;//设置系统时间格式
var
Locale: LCID;
begin
Locale := GetThreadLocale;
// 设置短日期格式
if not SetLocaleInfo(Locale, LOCALE_SSHORTDATE, PChar('yyyy-MM-dd')) then
begin
Application.MessageBox('设置系统时间格式错误', '错误', mb_OK + mb_IconError);
Beep;
end;
// 设置长日期格式,分隔符对长日期格式无效
if not SetLocaleInfo(Locale, LOCALE_SLONGDATE, PChar('yyyy''-''MM''-''dd')) then
begin
Application.MessageBox('设置系统日期格式错误', '错误', mb_OK + mb_IconError);
Beep;
end;
// 设置时间格式(Windows中没有长短之分)
if not SetLocaleInfo(Locale, LOCALE_STIMEFORMAT, PChar('HH:mm:ss')) then
begin
Application.MessageBox('设置时间格式错误', '错误', mb_OK + mb_IconError);
Beep;
end;
// 将改变通知其他应用程序
SendMessage(HWND_BROADCAST, WM_WININICHANGE, 0, 0);
end;
);
ParameterslpSystemTimePoints to a SYSTEMTIME structure that contains the current system date and time.
The wDayOfWeek member of the SYSTEMTIME structure is ignored. Return ValuesIf the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError. ResWindows NT: The SetSystemTime function fails if the calling process does not have the SE_SYSTEMTIME_NAME privilege. This privilege is disabled by default. Use the AdjustTokenPrivileges function to enable this privilege and again to disable it after the time has been set. For more information about security privileges, see Privileges.
Windows 95: Security privileges are not supported or required.
WORD wYear;
WORD wMonth;
WORD wDayOfWeek;
WORD wDay;
WORD wHour;
WORD wMinute;
WORD wSecond;
WORD wMilliseconds;
} SYSTEMTIME;
MemberswYearSpecifies the current year. wMonthSpecifies the current month; January = 1, February = 2, and so on. wDayOfWeekSpecifies the current day of the week; Sunday = 0, Monday = 1, and so on. wDaySpecifies the current day of the month. wHourSpecifies the current hour. wMinuteSpecifies the current minute. wSecondSpecifies the current second. wMillisecondsSpecifies the current millisecond. ResIt is not recommended that you add and subtract values from the SYSTEMTIME structure to obtain relative times. Instead, you should · Convert the SYSTEMTIME structure to a FILETIME structure.
· Copy the resulting FILETIME structure to a LARGE_INTEGER structure.
· Use normal 64-bit arithmetic on the LARGE_INTEGER value.