Check Daylight Saving Time with WMI on Vista / Win7

How do I know if daylight saving time works on my computer? (preferably using WMI)

According to this article in TechNet I can request SELECT DaylightInEffect FROM Win32_ComputerSystem, but the property is DaylightInEffectnot supported in Vista or Win7, Since my program will work on different systems (XP, Vista, 7), I would appreciate some portable search methods.

+1
source share
2 answers

The documented OS list is not accurate; it works fine on Win7 when I try it. I can not think of any reasons why it will not be supported on any other OS, it is easy to find out using the Win32 API (GetTimeZoneInformation).

WmiCodeCreator .

+3

, WMI, .

(: VBScript?)

Function IsDaylightInEffect()
    Const sComputer = "."

    Dim oWmiService : Set oWmiService = _
        GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _
                  & sComputer & "\root\cimv2")

    Set cItems = oWmiService.ExecQuery("SELECT * FROM Win32_ComputerSystem")

    For Each oItem In cItems
        IsDaylightInEffect = oItem.DaylightInEffect
        Exit For
    Next
End Function
+2

All Articles