Sunday, November 21, 2010

How do I make my program OS specific in vb.net?

Having some program trouble in vb.net.

Can someone give me a code example, like an if statement so that if the Os is windows XP then I run one line, but if its windows vista I run a different line. I tried google but to no success.

Thanks in advance!How do I make my program OS specific in vb.net?
You would need to use ';GetVersionEx'; from kernel32.dll. I'm not a VB fan, I use C++ and C# for all my application development needs. But I got that information from the MSDN web site. The VB.NET syntax is as follows (and it's at the bottom of the MSDN link I provided):



%26lt;DllImport(';kernel32.dll';, CharSet:=CharSet.Auto, SetLastError:=True)%26gt; _

Public Shared Function GetVersionEx(%26lt;[In], Out%26gt; ByVal ver As OSVERSIONINFO) As Boolean

End Function



Here's the descriptive link:



http://msdn.microsoft.com/en-us/library/鈥?/a>How do I make my program OS specific in vb.net?
System.Environment.OSVersion



http://msdn.microsoft.com/en-us/library/鈥?/a>
I found code to check for vista in C#.





VB.net : something like



Dim blnXP As Boolean = False

Dim blnVista As Boolean = False



Dim osInfo As System.Version = System.Environment.OSVersion.Version



Select Case osInfo.Major

Case Is = 6

blnVista = True

Case Is = 5

If osInfo.Minor %26gt; 1 Then

blnXP = True

End If

End Select

No comments:

Post a Comment