|
-
Jun 12th, 2006, 02:02 AM
#1
Thread Starter
New Member
[RESOLVED] Finding Operating System information
Hi
I am developeing an application in which i have to run some commands according to the operating system, so application should know on which Operating system it is running.
like is it running on windows 98 95 , XP or 2000
so i need a code which should tell me on which OS the application is currently running
Thanks
-
Jun 12th, 2006, 02:17 AM
#2
Re: Finding Operating System information
This is not a deployment question, it's a general VB question.
Try
VB Code:
Private Declare Function GetVersion Lib "kernel32" () As Long
Public Function GetWinVersion() As String
Dim Ver As Long, WinVer As Long
Ver = GetVersion()
WinVer = Ver And &HFFFF&
'retrieve the windows version
GetWinVersion = Format((WinVer Mod 256) + ((WinVer \ 256) / 100), "Fixed")
End Function
Private Sub Form_Load()
'KPD-Team 1999
'URL: [url]http://www.allapi.net/[/url]
MsgBox "Windows version: " + GetWinVersion
End Sub
You can also use GetVersionEx from AllAPI Guide.
-
Jun 12th, 2006, 03:53 AM
#3
Thread Starter
New Member
Re: Finding Operating System information
Thanks for info
The code you have given tells the versions of windows.
My question was. I need to know which Operating system?
That is it should tell me Windows Xp or Windows 98 not the version of the Windows.
-
Jun 12th, 2006, 04:15 AM
#4
Re: Finding Operating System information
Well the code posted above does just what you are looking for. It just needs a little more addition. Take a look at this
VB Code:
'API Function Which gets the Version Info of OS
Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long
Private Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128
End Type
'Function to Get the OS
Public Function GetOSName() As String
Dim OSV As OSVERSIONINFO
Dim lReturn As Long
OSV.dwOSVersionInfoSize = Len(OSV)
lReturn = GetVersionEx(OSV)
If OSV.dwMajorVersion = 4 And OSV.dwMinorVersion = 0 And OSV.dwPlatformId = 1 Then
GetOSName = "Windows 95"
ElseIf OSV.dwMajorVersion = 4 And OSV.dwMinorVersion = 10 Then
GetOSName = "Windows 98"
ElseIf OSV.dwMajorVersion = 4 And OSV.dwMinorVersion = 90 Then
GetOSName = "Windows 98 SE"
ElseIf OSV.dwMajorVersion = 3 And OSV.dwMinorVersion = 51 Then
GetOSName = "Windows NT 3.51"
ElseIf OSV.dwMajorVersion = 4 And OSV.dwMinorVersion = 0 And OSV.dwPlatformId = 2 Then
GetOSName = "Windows ME"
ElseIf OSV.dwMajorVersion = 5 And OSV.dwMinorVersion = 0 Then
GetOSName = "Windows 2000"
ElseIf OSV.dwMajorVersion = 5 And OSV.dwMinorVersion = 1 Then
GetOSName = "Windows XP"
End If
End Function
You can use GetOSName function to get the Operating System Name.
Use [code] source code here[/code] tags when you post source code.
My Articles
-
Jun 12th, 2006, 05:44 AM
#5
Thread Starter
New Member
Re: Finding Operating System information
Thanks alot for you help that really helped me
-
Jun 12th, 2006, 06:00 AM
#6
Re: Finding Operating System information
You are welcome 
Please mark your thread resolved by select Thread Tools at the top of this thread and select Mark Thread Resolved in the menu.
Use [code] source code here[/code] tags when you post source code.
My Articles
-
Jun 12th, 2006, 01:11 PM
#7
Re: [RESOLVED] Finding Operating System information
What you no read...
 Originally Posted by randem
You can also use GetVersionEx from AllAPI Guide.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|