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. :eek2:
Then this would have not been necessary.
vb.net Code:
Dim Full_Os_Name As String = My.Computer.Info.OSFullName
Dim User_Os As String
Sub Get_OS_NAME()
If Full_Os_Name.Contains("Windows 7") Then
User_Os = "Windows 7"
ElseIf Full_Os_Name.Contains("Windows Vista")Then
User_Os = "Windows Vista"
ElseIf Full_Os_Name.Contains("Windows XP")Then
User_Os = "Windows XP"
Else
MessageBox.Show(Full_Os_Name & " is not supported by: " & My.Application.Info.ProductName & ", Version " & My.Application.Info.Version.ToString)
Application.Exit()
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Get_OS_Name()
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. :lol:
If you like it, please vote my rep is struggling. :blush:
Re: Yet another way to check the OS name.
Quote:
Originally Posted by
Pc_Not_Mac
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. :eek2:
Then this would have not been necessary.
vb.net Code:
Dim Full_Os_Name As String = My.Computer.Info.OSFullName
Dim User_Os As String
Sub Get_OS_NAME()
If Full_Os_Name.Contains("Windows 7") Then
User_Os = "Windows 7"
ElseIf Full_Os_Name.Contains(Windows Vista")Then
User_Os = "Windows Vista"
ElseIf Full_Os_Name.Contains(Windows XP")Then
User_Os = "Windows XP"
Else
MessageBox.Show(Full_Os_Name & " is not supported by: " & My.Application.Info.ProductName & ", Version " & My.Application.Info.Version.ToString)
Application.Exit()
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call Get_OS_Name()
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. :lol:
If you like it, please vote my rep is struggling. :blush:
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.
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.
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. :wave:
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".
Re: Yet another way to check the OS name.
Quote:
Originally Posted by
Pc_Not_Mac
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.
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. :wave:
Re: Yet another way to check the OS name.
Re: Yet another way to check the OS name.
vb Code:
Label1.Text = My.Computer.Info.OSFullName
That's it.
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.
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