Hiding the System Clock on the fly

Does anyone know how to hide the system clock in the taskbar in 2000/XP?  I know about the registry entries at:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\HideClock
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\HideClock
HKEY_CURRENT_USER\Control Panel\don't load\timedate.cpl


And I modify them correctly and if I log out and back in, it works.  But I need this to happen on the fly.  I am already modifying several other Windows rights (access desktop, start button, etc...) and am using GPUPDATE (XP, SECEDIT for 2K) to update the policy and this works for everything I'm doing except the system clock.  When I go the taskbar properties and disable the clock, it happens immediately.  How can I get this to happen immediately like that?  Thanks.
LVL 5
codeconquerorAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Leo EikelmanDirector, IT and Business DevelopmentCommented:
try something like this

Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long

Private Sub HideClock_Click()
Dim FindClass As Long, FindParent As Long, Handle As Long
FindClass& = FindWindow("Shell_TrayWnd", vbNullString)
FindParent& = FindWindowEx(FindClass&, 0, "TrayNotifyWnd", vbNullString)
Handle& = FindWindowEx(FindParent&, 0, "TrayClockWClass", vbNullString)
ShowWindow Handle&, 0
End Sub

Private Sub ShowClock_Click()
Dim FindClass As Long, FindParent As Long, Handle As Long
FindClass& = FindWindow("Shell_TrayWnd", vbNullString)
FindParent& = FindWindowEx(FindClass&, 0, "TrayNotifyWnd", vbNullString)
Handle& = FindWindowEx(FindParent&, 0, "TrayClockWClass", vbNullString)
ShowWindow Handle&, 1
End Sub


Leo

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
codeconquerorAuthor Commented:
Thanks, trying that and testing right now.  Will post back in a bit with results.
codeconquerorAuthor Commented:
That worked perfectly.  I made an additional modification because it hid the clock, but the area was still there and could be double clicked and open the date/time settings.  Here is the ammended code in case anyone after me is trying to do this as well:

<CODE SNIPPET>
Private Sub HideClock()
Dim FindClass As Long, FindParent As Long, Handle As Long
FindClass& = FindWindow("Shell_TrayWnd", vbNullString)
FindParent& = FindWindowEx(FindClass&, 0, "TrayNotifyWnd", vbNullString)
Handle& = FindWindowEx(FindParent&, 0, "TrayClockWClass", vbNullString)
EnableWindow Handle&, False '**** This is the line I added
ShowWindow Handle&, 0
End Sub

Private Sub ShowClock()
Dim FindClass As Long, FindParent As Long, Handle As Long
FindClass& = FindWindow("Shell_TrayWnd", vbNullString)
FindParent& = FindWindowEx(FindClass&, 0, "TrayNotifyWnd", vbNullString)
Handle& = FindWindowEx(FindParent&, 0, "TrayClockWClass", vbNullString)
EnableWindow Handle&, True '**** This is the line I added
ShowWindow Handle&, 1
End Sub
</CODE SNIPPET>

Thanks for the quick help.  You rock.  :)
Leo EikelmanDirector, IT and Business DevelopmentCommented:
Thanks :)

Leo
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.