Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 281
  • Last Modified:

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.
0
codeconqueror
Asked:
codeconqueror
  • 2
  • 2
1 Solution
 
Leo EikelmanCommented:
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
0
 
codeconquerorAuthor Commented:
Thanks, trying that and testing right now.  Will post back in a bit with results.
0
 
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.  :)
0
 
Leo EikelmanCommented:
Thanks :)

Leo
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now