A guy at another forum I'm a member at posted code in response to a question about this, however his code didn't work properly and he only hinted to the types/api calls/etc that were used so I decided to rewrite it and include them here. After I finished just getting the basic OS name I wanted more information so I consulted MSDN. Anyway, this is more extensive than his code and I figure it'll be of use to somebody. I seperated the comments/code/usage to make it cleaner since it's pretty long.
Comments:
VB Code:
'This is an example of how to retreive your Operating System information. 'Special thanks to Noodlez for his code example at [url]http://forum.valhallalegends.com/phpbbs/index.php?board=17;action=display;threadid=615[/url] 'All of this information can be retreived through MSDN and by using the API Viewer 'This can be easily extended to include all suites (such as BackOffice) See: OSVERSIONEX 'To extend this even more and check if it's running on a 64-bit processor see [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/iswow64process.asp[/url] 'Main MSDN Resources Used: 'http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/getversionex.asp 'http://msdn.microsoft.com/library/en-us/sysinfo/base/getversionex.asp 'http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/osversioninfo_str.asp 'Types format supplied by MSDN 'typedef struct _OSVERSIONINFO { 'DWORD dwOSVersionInfoSize; 'DWORD dwMajorVersion; 'DWORD dwMinorVersion; 'DWORD dwBuildNumber; 'DWORD dwPlatformId; 'TCHAR szCSDVersion[128]; '} OSVERSIONINFO; ' 'typedef struct _OSVERSIONINFOEX { 'DWORD dwOSVersionInfoSize; 'DWORD dwMajorVersion; 'DWORD dwMinorVersion; 'DWORD dwBuildNumber; 'DWORD dwPlatformId; 'TCHAR szCSDVersion[128]; 'WORD wServicePackMajor; 'WORD wServicePackMinor; 'WORD wSuiteMask; 'BYTE wProductType; 'BYTE wReserved; '} OSVERSIONINFOEX, '*POSVERSIONINFOEX, '*LPOSVERSIONINFOEX; 'Supplied by MSDN (Suite Information) 'VER_SUITE_BACKOFFICE Microsoft BackOffice components are installed. 'VER_SUITE_BLADE Windows Server 2003, Web Edition is installed. 'VER_SUITE_DATACENTER Windows 2000 Datacenter Server or Windows Server 2003, Datacenter Edition is installed. 'VER_SUITE_ENTERPRISE Windows NT 4.0 Enterprise Edition, Windows 2000 Advanced Server, or Windows Server 2003, Enterprise Edition is installed. Refer to the Remarks section for more information about this bit flag. 'VER_SUITE_PERSONAL Windows XP Home Edition is installed. 'VER_SUITE_SMALLBUSINESS Microsoft Small Business Server was once installed on the system, but may have been upgraded to another version of Windows. Refer to the Remarks section for more information about this bit flag. 'VER_SUITE_SMALLBUSINESS_RESTRICTED Microsoft Small Business Server is installed with the restrictive client license in force. Refer to the Remarks section for more information about this bit flag. 'VER_SUITE_TERMINAL Terminal Services is installed. 'VER_SUITE_SINGLEUSERTS Terminal Services is installed, but only one interactive session is supported.
Declares:
VB Code:
Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long Private Declare Function GetVersionAdv Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFOEX) As Long Private Const WIN95 As String = "1.4.0" Private Const WIN98 As String = "1.4.10" Private Const WINME As String = "1.4.98" Private Const WINNT As String = "2.3.51" 'Windows NT 3.51 Private Const WINNT4 As String = "2.4.0" 'Windows NT 4 Private Const WIN2K As String = "2.5.0" Private Const WINXP As String = "2.5.1" Private Const WINNTS As String = "2.5.2" 'Windows Server 2k3 Private Type OSVERSIONINFO dwOSVersionInfoSize As Long 'Size = 148 dwMajorVersion As Long dwMinorVersion As Long dwBuildNumber As Long dwPlatformID As Long szCSDVersion As String * 128 End Type Private Type OSVERSIONINFOEX 'Only works if OS >= NT4 SP6 dwOSVersionInfoSize As Long 'Size = 156 dwMajorVersion As Long dwMinorVersion As Long dwBuildNumber As Long dwPlatformID As Long szCSDVersaion As String * 128 wServicePackMajor As Integer wServicePackMinor As Integer wSuiteMask As Integer wProductType As Byte wReserved As Byte End Type Private Enum WinProdType VER_NT_WORKSTATION = 1 'System = Win XP *, WIN NT 4, WIN 2K Pro VER_NT_DOMAIN_CONTROLLER = 2 'System = domain controller VER_NT_SERVER = 3 'System = server End Enum Private Enum WinSuiteMask VER_SUITE_SMALLBUSINESS = &H1 VER_SUITE_ENTERPRISE = &H2 VER_SUITE_BACKOFFICE = &H4 VER_SUITE_COMMUNICATIONS = &H8 VER_SUITE_TERMINAL = &H10 VER_SUITE_SMALLBUSINESS_RESTRICTED = &H20 VER_SUITE_EMBEDDEDNT = &H40 VER_SUITE_DATACENTER = &H80 VER_SUITE_SINGLEUSERTS = &H100 VER_SUITE_PERSONAL = &H200 VER_SUITE_BLADE = &H400 End Enum




Reply With Quote