Results 1 to 11 of 11

Thread: Yet another way to check the OS name.

  1. #1

    Thread Starter
    Frenzied Member Pc_Not_Mac's Avatar
    Join Date
    Oct 2009
    Location
    localhost
    Posts
    1,206

    Yet another way to check the OS name.

    The application that I'm working on needs to work different OS's.
    For example the glass effect that I have posted inside
    This is a very simple, and easy way to check the OS name.
    If Microsoft did not have 6 different version of each major release.
    Then this would have not been necessary.
    vb.net Code:
    1. Dim Full_Os_Name As String = My.Computer.Info.OSFullName
    2.     Dim User_Os As String
    3.     Sub Get_OS_NAME()
    4.         If Full_Os_Name.Contains("Windows 7") Then
    5.             User_Os = "Windows 7"
    6.         ElseIf Full_Os_Name.Contains("Windows Vista")Then
    7.             User_Os = "Windows Vista"
    8.         ElseIf Full_Os_Name.Contains("Windows XP")Then
    9.             User_Os = "Windows XP"
    10.         Else
    11.             MessageBox.Show(Full_Os_Name & " is not supported by: " & My.Application.Info.ProductName & ", Version " & My.Application.Info.Version.ToString)
    12.             Application.Exit()
    13.         End If
    14.     End Sub
    15.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    16.         Get_OS_Name()
    17.     End Sub
    Now you only have to compare "Windows 7", for example without comparing Windows Stater, Ultimate, Professional, Super Ultimate, Ultimate X2, and, Ultimate V5. You get the point.
    If you like it, please vote my rep is struggling.
    Last edited by Pc_Not_Mac; Jun 12th, 2011 at 02:26 PM. Reason: Removed some bugs. Thanks minitech.
    My Codebank:
    Windows Vista & 7 Glass Effect & Limit the amount of times your application could be opened.
    Pause Your Code & Check the OS name

    The question of whether computers can think is like the question of whether submarines can swim.

    Currently learning: Java

    Coding can be a learning experience or

  2. #2
    Fanatic Member
    Join Date
    Nov 2010
    Posts
    965

    Re: Yet another way to check the OS name.

    Quote Originally Posted by Pc_Not_Mac View Post
    The application that I'm working on needs to work different OS's.
    For example the glass effect that I have posted inside
    This is a very simple, and easy way to check the OS name.
    If Microsoft did not have 6 different version of each major release.
    Then this would have not been necessary.
    vb.net Code:
    1. Dim Full_Os_Name As String = My.Computer.Info.OSFullName
    2.     Dim User_Os As String
    3.     Sub Get_OS_NAME()
    4.         If Full_Os_Name.Contains("Windows 7") Then
    5.             User_Os = "Windows 7"
    6.         ElseIf Full_Os_Name.Contains(Windows Vista")Then
    7.             User_Os = "Windows Vista"
    8.         ElseIf Full_Os_Name.Contains(Windows XP")Then
    9.             User_Os = "Windows XP"
    10.         Else
    11.             MessageBox.Show(Full_Os_Name & " is not supported by: " & My.Application.Info.ProductName & ", Version " & My.Application.Info.Version.ToString)
    12.             Application.Exit()
    13.         End If
    14.     End Sub
    15.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    16.         Call Get_OS_Name()
    17.     End Sub
    Now you only have to compare "Windows 7", for example without comparing Windows Stater, Ultimate, Professional, Super Ultimate, Ultimate X2, and, Ultimate V5. You get the point.
    If you like it, please vote my rep is struggling.


    hi pc not mac. your program looks awesome but i will check until i understand it clearly. this time i am not understanding the line No 1, 2 and 11. so if you please assist me that i could use it.

  3. #3
    Stack Overflow mod​erator
    Join Date
    May 2008
    Location
    British Columbia, Canada
    Posts
    2,824

    Re: Yet another way to check the OS name.

    You forgot a few quotes... also, you should note that "Call" is redundant in this case (though not always).

    A couple of suggestions: don't check for "Windows" each time. We know if it's "7", "XP", or "Vista" it's Windows, especially since .NET only truly runs on Windows right now. Also you should use an enumeration, to increase efficiency and avoid that annoying case-sensitivity. Or at least use constants so people don't have to check back.

  4. #4

    Thread Starter
    Frenzied Member Pc_Not_Mac's Avatar
    Join Date
    Oct 2009
    Location
    localhost
    Posts
    1,206

    Re: Yet another way to check the OS name.

    Quote Originally Posted by minitech
    don't check for "Windows" each time. We know if it's "7", "XP", or "Vista" it's Windows, especially since .NET only truly runs on Windows right now
    Not sure if I completely understand that.
    This example is useful when something works on one, but not the other.
    For example, the progress bar on each task in the taskbar only works on "7".
    The glass effect would only work on "Vista", or "7".
    Try loading the glass effect on XP and you will error out.

    Quote Originally Posted by minitech
    Also you should use an enumeration, to increase efficiency and avoid that annoying case-sensitivity. Or at least use constants so people don't have to check back.
    I might look into that when my SSD gets here.

    Quote Originally Posted by minitech
    You forgot a few quotes... also, you should note that "Call" is redundant in this case (though not always).
    Thanks btw.
    My Codebank:
    Windows Vista & 7 Glass Effect & Limit the amount of times your application could be opened.
    Pause Your Code & Check the OS name

    The question of whether computers can think is like the question of whether submarines can swim.

    Currently learning: Java

    Coding can be a learning experience or

  5. #5

    Thread Starter
    Frenzied Member Pc_Not_Mac's Avatar
    Join Date
    Oct 2009
    Location
    localhost
    Posts
    1,206

    Re: Yet another way to check the OS name.

    Quote Originally Posted by ADQUSITADQUSIT
    hi pc not mac. your program looks awesome but i will check until i understand it clearly. this time i am not understanding the line No 1, 2 and 11. so if you please assist me that i could use it.
    Line 1 gets the users full OS name:
    for example,
    Microsoft Windows 7 Professional Edition.
    Line 11, is just a message box.
    Line 2, is a simple sting to store shorted name of the OS. Like "Windows 7".
    My Codebank:
    Windows Vista & 7 Glass Effect & Limit the amount of times your application could be opened.
    Pause Your Code & Check the OS name

    The question of whether computers can think is like the question of whether submarines can swim.

    Currently learning: Java

    Coding can be a learning experience or

  6. #6
    Fanatic Member
    Join Date
    Nov 2010
    Posts
    965

    Re: Yet another way to check the OS name.

    Quote Originally Posted by Pc_Not_Mac View Post
    Line 1 gets the users full OS name:
    for example,
    Microsoft Windows 7 Professional Edition.
    Line 11, is just a message box.
    Line 2, is a simple sting to store shorted name of the OS. Like "Windows 7".
    thats fine now.

    If i got some other problem so i'll ask for assistance.

    now please tell me that where do i write this code. i mean just simply on form load event or somewhere else.

  7. #7

    Thread Starter
    Frenzied Member Pc_Not_Mac's Avatar
    Join Date
    Oct 2009
    Location
    localhost
    Posts
    1,206

    Re: Yet another way to check the OS name.

    Quote Originally Posted by ADQUSIT
    now please tell me that where do i write this code. i mean just simply on form load event or somewhere else.
    You can but I made a sub for the method.
    Just call Full_Os_Name anytime you want to run it.
    You only need to run it ones so keep it in the load event.
    I personal avoid having any code inside the load event as it gets cultured with methods.
    My Codebank:
    Windows Vista & 7 Glass Effect & Limit the amount of times your application could be opened.
    Pause Your Code & Check the OS name

    The question of whether computers can think is like the question of whether submarines can swim.

    Currently learning: Java

    Coding can be a learning experience or

  8. #8

  9. #9
    Lively Member
    Join Date
    May 2011
    Posts
    86

    Re: Yet another way to check the OS name.

    vb Code:
    1. Label1.Text = My.Computer.Info.OSFullName
    That's it.

  10. #10

    Thread Starter
    Frenzied Member Pc_Not_Mac's Avatar
    Join Date
    Oct 2009
    Location
    localhost
    Posts
    1,206

    Re: Yet another way to check the OS name.

    Quote Originally Posted by rami0
    1.
    Label1.Text = My.Computer.Info.OSFullName

    That's it.
    Nice. That was completely irrelevant and off-topic.
    Next time try reading the first post rather than, the title and skipping to the code.
    My Codebank:
    Windows Vista & 7 Glass Effect & Limit the amount of times your application could be opened.
    Pause Your Code & Check the OS name

    The question of whether computers can think is like the question of whether submarines can swim.

    Currently learning: Java

    Coding can be a learning experience or

  11. #11
    New Member
    Join Date
    Aug 2014
    Posts
    4

    Re: Yet another way to check the OS name.

    Hey, PC_not_Mac,
    I am using your code. I will run it and see what it does!
    vbdotnetfan

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