none
GetSystemMetrics(SM_SERVERR2) Problem RRS feed

  • Question

  • Hi,

    In a legacy VB6 app, I am using GetVersionExA to get Windows Version:

    https://docs.microsoft.com/en-us/windows/desktop/sysinfo/operating-system-version

    But how to distinguish Windows Server 2003 and 2003 R2, I found the only way would be:

    GetSystemMetrics(SM_SERVERR2)

    So I have:

    Public Declare Function GetSystemMetrics Lib "user32" (nIndex As Long) As Long
    
    Const SM_SERVERR2 As Long = 89&
    
           If GetSystemMetrics(SM_SERVERR2) = 0 Then
            GetVersion = "Windows Server 2003"
           Else
            GetVersion = "Windows Server 2003 R2"
           End If
    The problem is that GetSystemMetrics(SM_SERVERR2) ALWAYS RETURN 0, no matter if on 2003 or 2003 R2!

    Am I missing something in my code or somewhere else?

    Sunday, June 23, 2019 7:41 AM

All replies