Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OnChangeSystemDate ? 1

Status
Not open for further replies.

Gigatech

Programmer
Jul 12, 2000
80
CR
I use D7. I need to handle the Change System Date or Time event. For example, when the user changes the system date (or time) through the Control Panel or command window (DOS), I need to evaluate if I want the user does that. If I don´t, I need to forbid the user proced with the change.

is something like:

Proced OnChangeSystemDateTime;
begin
if user has privileges then
let the user make the change
else
raise an exception
end;

Thanks
 
In W2K/XP it is simple: remove the privilege "SeSystemtimePrivilege" to users you want unable to change the system date, add the privilege to the ones you want able to.

In Win9x it is somewhat difficult: when the date/time is changed the system broadcast the message WM_TIMECHANGE to all top level windows... but you can't not stop the change and you have not warranty of getting the message first (ie: before the other top windows) no matter where you think you are in the Z order.

Setting back the time when receiving the signal is your only option, but you need to take some issues in account:

a) You need to know the original time to set it back.

b.1) Setting the time will fire another WM_TIMECHANGE, beware recursion if you are doing it inside the WM_TIMECHANGE handler. It is possible to do it right, but please considere b.2 first.

b.2) Better not changing the time in the handler. Post (not send) a special message (WM_USER + xxx) to your app, telling him to set the time back and leave the handler immediately; the app message loop will get your message next time it checks its queue (ie: outside the WM_TIMECHANGE handler).

buho (A).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top