![]() |
| ||
|
|
Новости |
Поиск |
FAQ |
Статьи |
Книги |
Новости VCL
| | Форумы ЧАТ |
Орешник |
|
| |||
| |||
« предыдущая ветвь | форум | следующая ветвь »
Надо уменьшать системное время ? [D5, D6, Win95/98, WinXP]
Дмитрий Д. © (2002-07-24 07:49:00)подскажите где я не прав ?
var
NewTime: SYSTEMTIME;
Year, Month,Day, Hour, Min, Sec, MSec: Word;
begin
DecodeTime(now, Hour, Min, Sec, MSec);
DecodeDate(now, Year, Month, Day);
NewTime.wYear := Year;
NewTime.wMonth := Month;
NewTime.wDayOfWeek:=DayOfWeek(now);
NewTime.wDay := Day;
NewTime.wHour := Hour;
NewTime.wMinute := Min-1;
NewTime.wSecond := 0;
NewTime.wMilliseconds := 0;
setsystemtime(NewTime);
и будет ли работать такой код под ХР ?
han_malign (2002-07-24 10:51:00) [1]2002/10/23:15.00.00.00
==>
2002/10/23:15. -1.00.00 ??? (word(-1)=$FFFF)
P.S. DateTimeToSystemTime(now-1/(24*60),NewTime)- без всяких коллизий (даже в Новый Год - на високосный), все остальное Win32 API и должно работать (разве что с правами админа какая бяка).
P.P.S.
Remarks
Windows 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 AdjustTokenPrivilegesfunction 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.
P.P.P.S
now- дает локальное время, а SetSystemTimeустанавливает UTC,
так что пользовать нужно SetLocalTime