Results 1 to 7 of 7

Thread: [2008] WinXP and Vista

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2007
    Posts
    167

    [2008] WinXP and Vista

    I didnt use Win Vista yet so I dont know if the coding for WinXP would work for Win Vista.
    I have few questions:
    1)Is there a code to find out what windows is the user using? (XP or Vista)
    2)Is Registry the same? Can a program that work with WinXP work with Win Vista's Registry without any additional codes (something to get privialge maybe?)
    3)what else should we care about if we're making a program to run on both WinXP and WinVista?

    thanks for your help

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,424

    Re: [2008] WinXP and Vista

    heres an example for getting OS version.
    i'm not sure how to get OS if vista, but it'll be similar to the other OS's

    vb Code:
    1. Public Class Form1
    2.  
    3.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    4.         MsgBox(OS_Version)
    5.     End Sub
    6.  
    7.     Public Function OS_Version() As String
    8.  
    9.         Dim osInfo As OperatingSystem
    10.         Dim sAns As String = ""
    11.  
    12.         osInfo = System.Environment.OSVersion
    13.  
    14.         With osInfo
    15.             Select Case .Platform
    16.                 Case 1 '.Platform.Win32Windows
    17.                     Select Case (.Version.Minor)
    18.                         Case 0
    19.                             sAns = "Windows 95"
    20.                         Case 10
    21.                             If .Version.Revision.ToString() = "2222A" Then
    22.                                 sAns = "Windows 98 Second Edition"
    23.                             Else
    24.                                 sAns = "Windows 98"
    25.                             End If
    26.                         Case 90
    27.                             sAns = "Windows Me"
    28.                     End Select
    29.                 Case 2 '.Platform.Win32NT
    30.                     Select Case (.Version.Major)
    31.                         Case 3
    32.                             sAns = "Windows NT 3.51"
    33.                         Case 4
    34.                             sAns = "Windows NT 4.0"
    35.                         Case 5
    36.                             If .Version.Minor = 0 Then
    37.                                 sAns = "Windows 2000"
    38.                             ElseIf .Version.Minor = 1 Then
    39.                                 sAns = "Windows XP"
    40.                             ElseIf .Version.Minor = 2 Then
    41.                                 sAns = "Windows Server 2003"
    42.                             Else 'Future version maybe update
    43.                                 'as needed
    44.                                 sAns = "Unknown Windows Version"
    45.                             End If
    46.                     End Select
    47.  
    48.             End Select
    49.         End With
    50.  
    51.         Return sAns
    52.  
    53.     End Function
    54.  
    55. End Class

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

    Re: [2008] WinXP and Vista

    The posted code wont detect Vista. Here is the additional code with changes to work with Option Strict On
    VB.NET Code:
    1. Option Explicit On
    2. Option Strict On
    3.  
    4. Public Class Form1
    5.  
    6.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    7.         MessageBox.Show(OS_Version, "Operating System Version", MessageBoxButtons.OK, MessageBoxIcon.Information)
    8.     End Sub
    9.  
    10.     Public Function OS_Version() As String
    11.  
    12.         Dim osInfo As OperatingSystem
    13.         Dim sAns As String = ""
    14.  
    15.         osInfo = System.Environment.OSVersion
    16.         With osInfo
    17.             Select Case DirectCast(.Platform, Integer)
    18.                 Case 1 '.Platform.Win32Windows
    19.                     Select Case (.Version.Minor)
    20.                         Case 0
    21.                             sAns = "Windows 95"
    22.                         Case 10
    23.                             If .Version.Revision.ToString() = "2222A" Then
    24.                                 sAns = "Windows 98 Second Edition"
    25.                             Else
    26.                                 sAns = "Windows 98"
    27.                             End If
    28.                         Case 90
    29.                             sAns = "Windows Me"
    30.                     End Select
    31.                 Case 2 '.Platform.Win32NT
    32.                     Select Case (.Version.Major)
    33.                         Case 3
    34.                             sAns = "Windows NT 3.51"
    35.                         Case 4
    36.                             sAns = "Windows NT 4.0"
    37.                         Case 5
    38.                             If .Version.Minor = 0 Then
    39.                                 sAns = "Windows 2000"
    40.                             ElseIf .Version.Minor = 1 Then
    41.                                 sAns = "Windows XP"
    42.                             ElseIf .Version.Minor = 2 Then
    43.                                 sAns = "Windows Server 2003"
    44.                             Else 'Future version maybe update
    45.                                 'as needed
    46.                                 sAns = "Unknown Windows Version"
    47.                             End If
    48.                         Case 6
    49.                             sAns = "Windows Vista" & " " & .ServicePack
    50.                             'Or you can return the actual version
    51.                             'sAns = .VersionString & " " & .ServicePack
    52.                     End Select
    53.  
    54.             End Select
    55.         End With
    56.         Return sAns
    57.     End Function
    58.  
    59. End Class


    Second, yes there are major changes with the registry. No longer can you simply access the registry. The User Account Control popup will control it if the user has Administrator permissions or can get an Administrator to fill in the logon prompt for elevating the process to Administrator so the process can read the registry.
    Also, there are more protected directories. No longer can you store shared data in the Application.StartupDirectory.

    Basically, anything that does work on XP will probably fail on Vista unless you code accordingly for the new security and directory changes..
    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

  4. #4
    Frenzied Member toecutter's Avatar
    Join Date
    Apr 2006
    Location
    Brisbane, Australia
    Posts
    1,160

    Re: [2008] WinXP and Vista

    I hade a similar question regarding the My Music folder in xp as vista now calls it just Music.
    But as usual the legend helped me out.
    This will find the default Music folder on xp or vista
    Quote Originally Posted by jmcilhinney
    Wouldn't
    vb.net Code:
    1. Environment.GetFolderPath(Environment.SpecialFolder.MyMusic)
    just return the correct folder path for the current OS?

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

    Re: [2008] WinXP and Vista

    Um is this the right thread you are replying to? Ths thread is about detecting the OS version.
    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

  6. #6
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: [2008] WinXP and Vista

    Quote Originally Posted by RobDog888
    Um is this the right thread you are replying to? Ths thread is about detecting the OS version.
    I think toecutter was answering peritos 3rd question
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

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

    Re: [2008] WinXP and Vista

    Oh well um its still called "Music" which isnt really that different from "My Music". Then the constant is the same value still so programmatically accessing it is done not by name but by constant value.
    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

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