Results 1 to 13 of 13

Thread: [RESOLVED] Get Windows Version

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2006
    Posts
    91

    Resolved [RESOLVED] Get Windows Version

    Is there a way to get the version of the windows in few lines?!
    because i have to write a lot and alot of codes to get it !!!!

  2. #2

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Sep 2006
    Posts
    91

    Re: Get Windows Version

    thnax
    my code is shorter than link "Windows Version, Service Pack and Platform Info"

  4. #4

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Sep 2006
    Posts
    91

    Re: Get Windows Version

    I think so
    i use this code , if there a comment plz post it


    VB Code:
    1. Public Type OSVERSIONINFOEX
    2.     dwOSVersionInfoSize As Long
    3.     dwMajorVersion As Long
    4.     dwMinorVersion As Long
    5.     dwBuildNumber As Long
    6.     dwPlatformId As Long
    7.     szCSDVersion As String * 128
    8. End Type
    9.  
    10. Public Const VER_PLATFORM_WIN32s = 0
    11. Public Const VER_PLATFORM_WIN32_WINDOWS = 1
    12. Public Const VER_PLATFORM_WIN32_NT = 2
    13.  
    14. Declare Function GetVersionEx Lib "kernel32" _
    15. Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFOEX) As Long
    16.  
    17. Public Function OSVersion() As String
    18.    
    19.     Dim udtOSVersion As OSVERSIONINFOEX
    20.     Dim lMajorVersion  As Long
    21.     Dim lMinorVersion As Long
    22.     Dim lPlatformID As Long
    23.     Dim sAns As String
    24.    
    25.    
    26.     udtOSVersion.dwOSVersionInfoSize = Len(udtOSVersion)
    27.     GetVersionEx udtOSVersion
    28.     lMajorVersion = udtOSVersion.dwMajorVersion
    29.     lMinorVersion = udtOSVersion.dwMinorVersion
    30.     lPlatformID = udtOSVersion.dwPlatformId
    31.    
    32.     Select Case lMajorVersion
    33.         Case 5
    34.             sAns = "Windows XP"
    35.         Case 4
    36.             If lPlatformID = VER_PLATFORM_WIN32_NT Then
    37.                 sAns = "Windows NT 4.0"
    38.             Else
    39.                 sAns = IIf(lMinorVersion = 0, _
    40.                 "Windows 98", "Windows ME")
    41.             End If
    42.         Case 3
    43.             If lPlatformID = VER_PLATFORM_WIN32_NT Then
    44.                 sAns = "Windows NT 3.x"
    45.             Else
    46.                 sAns = "Windows 3.x"
    47.             End If
    48.            
    49.         Case Else
    50.             sAns = "Unknown Windows Version"
    51.     End Select
    52.                    
    53.     OSVersion = sAns
    54.    
    55. End Function


    form code
    VB Code:
    1. Text1.Text=OSVersion

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Get Windows Version

    It doesnt differenciate between 95/98,ME. Also, no Server OS' detection, Vista and Vista versions, XP and XP version, any revisions and or service packs etc.

    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7
    Frenzied Member cssriraman's Avatar
    Join Date
    Jun 2005
    Posts
    1,465

    Re: Get Windows Version

    Last edited by cssriraman; Nov 6th, 2006 at 07:10 AM.
    CS

  8. #8
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Get Windows Version

    My VB.NET code that could easily be converted back to legacy VB 6 code.

    http://vbforums.com/showthread.php?t=434149
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  9. #9
    PowerPoster Keithuk's Avatar
    Join Date
    Jan 2004
    Location
    Staffordshire, England
    Posts
    2,236

    Re: Get Windows Version

    This About Form with OSInfo.cls will show all versions of Windows accept XP. Mine shows the difference between Win98 and Win98se. If you want to modify it to show WinXP great just mod it and post it back.
    Attached Files Attached Files
    Last edited by Keithuk; Nov 6th, 2006 at 07:36 AM.
    Keith

    I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.

  10. #10
    Hyperactive Member Jenova's Avatar
    Join Date
    Feb 2006
    Location
    Googleplex
    Posts
    413

    Re: Get Windows Version

    How would you differentiate between OS Versions? For example, Windows XP Home and Professional.

  11. #11
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Get Windows Version

    Its shown in my code example which can be used to update keiths example.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  12. #12

  13. #13

    Thread Starter
    Lively Member
    Join Date
    Sep 2006
    Posts
    91

    Re: Get Windows Version

    Thanks for you all

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width