Announcement

Collapse
No announcement yet.

ID'ing Server vs Professional

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • ID'ing Server vs Professional

    Is there an api call to determine the difference between Win2k pro and Win2k server?

    GetWindowsVersionEx does not seem to do that, I ran it on pro and server and saw no differences whatsoever..


    Scott

    ------------------
    Scott
    Scott Turchin
    MCSE, MCP+I
    http://www.tngbbs.com
    ----------------------
    True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

  • #2
    Scott,

    Try this url at MSDN. It's in C but easy to decipher!
    http://msdn.microsoft.com/library/ps...sinfo_92jy.htm

    Cheers,
    Cecil

    ------------------




    [This message has been edited by Cecil Williams (edited April 17, 2001).]

    Comment


    • #3
      So it's the normal GetVersion info but you also probe the registry key for this:

      HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ProductOptions


      Now, interesting that when I fired up Terminal server to get into my server at home the registry shows these two string's under that key:

      ProductSuite:Terminal Server
      ProductType: LanmanNT

      It should read, if running on normal NT/2k server (Or running from console not TS), "SERVERNT"


      Thanks!
      I'll update my code 2nite and post it in the source code forum....

      Scott

      ------------------
      Scott
      Scott Turchin
      MCSE, MCP+I
      http://www.tngbbs.com
      ----------------------
      True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

      Comment


      • #4
        Houston We have a problem...

        According to Microsoft, A TYPE of OSVERSIONINFOEX can now be passed to GetVersionEx....


        Great, but our Win32api.inc file has these declarations:
        DECLARE FUNCTION GetVersion LIB "KERNEL32.DLL" ALIAS "GetVersion" () AS LONG
        DECLARE FUNCTION GetVersionEx LIB "KERNEL32.DLL" ALIAS "GetVersionExA" (lpVersionInformation AS OSVERSIONINFO) AS LONG

        How do I get around that one and still be able to use GetVersionEX with OSVERSIONINFO without the EX????

        Sorta back to that datatype question.....

        Almost there too

        ------------------
        Scott



        [This message has been edited by Scott Turchin (edited April 18, 2001).]
        Scott Turchin
        MCSE, MCP+I
        http://www.tngbbs.com
        ----------------------
        True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

        Comment


        • #5
          Use BYVAL in the calling code to disable type checking for that parameter, and pass the address of the EX structure, thus:
          Code:
          DIM OVIX AS OSVERSIONINFOEX
          ...
          CALL GetVersionEx(BYVAL VARPTR(OVIX))
          ------------------
          Lance
          PowerBASIC Support
          mailto:[email protected][email protected]</A>
          Lance
          mailto:[email protected]

          Comment


          • #6
            OK Cat's outta the bag, wanted to complete this on my own but I'm stuck!!

            I copied win32api.inc to my programs folder and modified the GetVersionEx as such:
            I also tried Byval before I changed it:

            Code:
            DECLARE FUNCTION GetVersionEx LIB "KERNEL32.DLL" ALIAS "GetVersionExA" (lpVersionInformation AS OSVERSIONINFOEX) AS LONG
            
            '
            '
            '
            %VER_NT_WORKSTATION                 = &H00000001
            %VER_NT_DOMAIN_CONTROLLER           = &H00000002
            %VER_NT_SERVER                      = &H00000003
            %VER_SUITE_SMALLBUSINESS            = &H00000001
            %VER_SUITE_ENTERPRISE               = &H00000002
            %VER_SUITE_BACKOFFICE               = &H00000004
            %VER_SUITE_COMMUNICATIONS           = &H00000008
            %VER_SUITE_TERMINAL                 = &H00000010
            %VER_SUITE_SMALLBUSINESS_RESTRICTED = &H00000020
            %VER_SUITE_EMBEDDEDNT               = &H00000040
            %VER_SUITE_DATACENTER               = &H00000080
            %VER_SUITE_SINGLEUSERTS             = &H00000100
            %VER_SUITE_PERSONAL                 = &H00000200
            %VER_SUITE_SERVERAPPLIANCE          = &H00000400
            %ERROR_OLD_WIN_VERSION              = 0
            
            Type OSVERSIONINFOEX
              dwOSVersionInfoSize As Long
              dwMajorVersion As Long
              dwMinorVersion As Long
              dwBuildNumber As Long
              dwPlatformId As Long
              szCSDVersion As Asciiz * 128
              wServicePackMajor As Long  'Word?
              wServicePackMinor As Long  'Word?
              wSuiteMask As Long    'Word?
              wProductType As Byte
              wReserved As Byte
            End Type
            
            #Include "H:\PBCC\OSVER\Win32api.inc"
            Declare Function DisplaySystemVersion() As String
            
            Function PbMain() As Long
            StdOut DisplaySystemVersion
            End Function
            '============================================================================================
            Function DisplaySystemVersion() As String
            Dim osvi        As OSVERSIONINFOEX
            Local lResult   As Long
            Local St        As String
            Local NTVer     As String
            Local ExWorked  As String
            Local bOsVersionInfoEx As Long
            
            Local hKey As Long
            Local szProductType As Asciiz * 80
            Local dwBufLen As Long
            osvi.dwOsVersionInfoSize = SizeOf(osvi)
            bOsVersionInfoEx = GetVersionEx(osvi)
            
            If bOsVersionInfoEx = %ERROR_OLD_WIN_VERSION Then 'It failed
                StdOut "GetVersionEx failed with the following error: " & Format$(bOsVersionInfoEx)
            End If
            Select Case osvi.dwPlatformId
                   Case %VER_PLATFORM_WIN32_NT
                        '// Test for the product.
                        If osvi.dwMajorVersion <= 4 Then St = "Microsoft Windows NT "
                        If osvi.dwMajorVersion = 5 And osvi.dwMinorVersion = 0 Then  St = "Microsoft Windows 2000 "
                        If osvi.dwMajorVersion = 5 And osvi.dwMinorVersion = 1 Then  St = "Whistler "
            
                        '// Test for product type.
                        If IsTrue bOsVersionInfoEx Then 'Test for product type
                           If osvi.wProductType = %VER_NT_WORKSTATION Then
                                  If osvi.wSuiteMask & %VER_SUITE_PERSONAL Then
                                     St = St & " Personal "
                                  Else
                                     St = St & " Professional "
                                  End If
                           ElseIf osvi.wProductType = %VER_NT_SERVER Then
                              If osvi.wSuiteMask & %VER_SUITE_DATACENTER Then
                                 St = St & "DataCenter Server "
                              ElseIf osvi.wSuiteMask & %VER_SUITE_ENTERPRISE Then
                                 St = St & "Advanced Server "
                              Else
                                 St = St & "Server "
                              End If
                           End If
            
                        Else 'Probe the registry
                            RegOpenKeyEx %HKEY_LOCAL_MACHINE, "SYSTEM\CurrentControlSet\Control\ProductOptions",0, %KEY_QUERY_VALUE, hKey
                            RegQueryValueEx hKey,_
                                            "ProductType",_
                                            0,_
                                            0,_
                                            szProductType,_
                                            dwBufLen
            
                            RegCloseKey hKey
                            If szProductType = "WINNT" Then
                               St = St & "Workstation "
                            ElseIf szProductType = "SERVERNT" Then
                               St = St & "Server "
                            ElseIf szProductType = "LanmanNT" Then
                               St = St & "Terminal Server "
                            End If
                        End If
            
                        '// Display version, service pack (If Any), And build number.
                        If osvi.dwMajorVersion <= 4 Then
                           St = St & "version " & Format$(osvi.dwMajorVersion) & "." & Format$(osvi.dwMinorVersion) & " " & osvi.szCSDVersion & " (Build " & Format$(osvi.dwBuildNumber & 65535) & ")"
                        Else
                           St = St & osvi.szCSDVersion & " (Build " & Format$(osvi.dwBuildNumber & 65535) & ")"
                        End If
            
            
                   Case %VER_PLATFORM_WIN32_WINDOWS
                        If (osvi.dwMajorVersion = 4 & osvi.dwMinorVersion = 0) Then
                           St = "Microsoft Windows 95 "
                           If Left$(osvi.szCSDVersion,1) = "C" Then St = St & "OSR2 "
                        End If
                        If (osvi.dwMajorVersion = 4 & osvi.dwMinorVersion = 10) Then
                           St = "Microsoft Windows 98 "
                           If Left$(osvi.szCSDVersion,1) = "A" Then St = St & "SE "
                        End If
                        If (osvi.dwMajorVersion = 4 & osvi.dwMinorVersion = 90) Then
                           St = "Microsoft Windows ME "
                        End If
            
                   Case %VER_PLATFORM_WIN32s
                        St = "Microsoft Win32s "
            End Select
            Function = St
            End Function
            ------------------
            Scott

            [This message has been edited by Scott Turchin (edited April 18, 2001).]
            Scott Turchin
            MCSE, MCP+I
            http://www.tngbbs.com
            ----------------------
            True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

            Comment


            • #7
              The proper TYPE might help, and you may need to tag your program as being
              Win2k-aware with an #OPTION VERSION5 command.
              Code:
              TYPE OSVERSIONINFOEX
                dwOSVersionInfoSize AS DWORD
                dwMajorVersion AS DWORD
                dwMinorVersion AS DWORD
                dwBuildNumber AS DWORD
                dwPlatformId AS DWORD
                szCSDVersion AS ASCIIZ * 128
                wServicePackMajor AS WORD
                wServicePackMinor AS WORD
                wSuiteMask AS WORD
                wProductType AS BYTE
                wReserved AS BYTE
              END TYPE

              ------------------
              Tom Hanlin
              PowerBASIC Staff

              Comment


              • #8
                I Thought of that as well, the TYPE, but I looked at the OSVERSIONINFO (old) and it uses long's instead of DWORDS for the same masks....Hmmm I'll give it a shot!!!

                Thanks,

                Scott


                ------------------
                Scott
                Scott Turchin
                MCSE, MCP+I
                http://www.tngbbs.com
                ----------------------
                True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

                Comment


                • #9
                  Changed over, used option version5 and still a no go...
                  Perhaps it's only on Whistler and ME that it will work....
                  I'll keep plugging away though


                  ------------------
                  Scott
                  Scott Turchin
                  MCSE, MCP+I
                  http://www.tngbbs.com
                  ----------------------
                  True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

                  Comment


                  • #10
                    Scott,

                    Been out of pocket a day or so.

                    The author of the "C" code that I referred to was using
                    GetVersionEx and passing OSVERSIONINFOEX first. OSVERSIONINFOEX
                    requires NT5 or better. If the call to OSVERSIONINFOEX failed,
                    then OSVERSIONINFO was called. If OSVERSIONINFO, which requires
                    NT3.51 or better fails, exit the function.

                    Now, I see some really weird bitwise operators in your code.
                    In translating the "C" code, you apparently brought the C
                    bitwise "&"(AND) over into PB. Doesn't mean the same here.
                    Recheck your all code in your select case block. I believe
                    you'll see the problem.

                    Cheers,
                    Cecil

                    ------------------

                    Comment

                    Working...
                    X