Results 1 to 9 of 9

Thread: Finding OS Information

Threaded View

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 2003
    Location
    USA
    Posts
    21

    Finding OS Information

    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:
    1. 'This is an example of how to retreive your Operating System information.
    2. 'Special thanks to Noodlez for his code example at [url]http://forum.valhallalegends.com/phpbbs/index.php?board=17;action=display;threadid=615[/url]
    3. 'All of this information can be retreived through MSDN and by using the API Viewer
    4. 'This can be easily extended to include all suites (such as BackOffice) See: OSVERSIONEX
    5. '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]
    6.  
    7.  
    8. 'Main MSDN Resources Used:
    9. 'http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/getversionex.asp
    10. 'http://msdn.microsoft.com/library/en-us/sysinfo/base/getversionex.asp
    11. 'http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/osversioninfo_str.asp
    12.  
    13.  
    14. 'Types format supplied by MSDN
    15.  
    16. 'typedef struct _OSVERSIONINFO {
    17. 'DWORD dwOSVersionInfoSize;
    18. 'DWORD dwMajorVersion;
    19. 'DWORD dwMinorVersion;
    20. 'DWORD dwBuildNumber;
    21. 'DWORD dwPlatformId;
    22. 'TCHAR szCSDVersion[128];
    23. '} OSVERSIONINFO;
    24. '
    25. 'typedef struct _OSVERSIONINFOEX {
    26. 'DWORD dwOSVersionInfoSize;
    27. 'DWORD dwMajorVersion;
    28. 'DWORD dwMinorVersion;
    29. 'DWORD dwBuildNumber;
    30. 'DWORD dwPlatformId;
    31. 'TCHAR szCSDVersion[128];
    32. 'WORD wServicePackMajor;
    33. 'WORD wServicePackMinor;
    34. 'WORD wSuiteMask;
    35. 'BYTE wProductType;
    36. 'BYTE wReserved;
    37. '} OSVERSIONINFOEX,
    38. '*POSVERSIONINFOEX,
    39. '*LPOSVERSIONINFOEX;
    40.  
    41. 'Supplied by MSDN (Suite Information)
    42. 'VER_SUITE_BACKOFFICE Microsoft BackOffice components are installed.
    43. 'VER_SUITE_BLADE Windows Server 2003, Web Edition is installed.
    44. 'VER_SUITE_DATACENTER Windows 2000 Datacenter Server or Windows Server 2003, Datacenter Edition is installed.
    45. '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.
    46. 'VER_SUITE_PERSONAL Windows XP Home Edition is installed.
    47. '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.
    48. '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.
    49. 'VER_SUITE_TERMINAL Terminal Services is installed.
    50. 'VER_SUITE_SINGLEUSERTS Terminal Services is installed, but only one interactive session is supported.

    Declares:
    VB Code:
    1. Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long
    2. Private Declare Function GetVersionAdv Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFOEX) As Long
    3.  
    4.  
    5. Private Const WIN95 As String = "1.4.0"
    6. Private Const WIN98 As String = "1.4.10"
    7. Private Const WINME As String = "1.4.98"
    8. Private Const WINNT As String = "2.3.51" 'Windows NT 3.51
    9. Private Const WINNT4 As String = "2.4.0" 'Windows NT 4
    10. Private Const WIN2K As String = "2.5.0"
    11. Private Const WINXP As String = "2.5.1"
    12. Private Const WINNTS As String = "2.5.2" 'Windows Server 2k3
    13.  
    14.  
    15. Private Type OSVERSIONINFO
    16.     dwOSVersionInfoSize As Long 'Size = 148
    17.     dwMajorVersion As Long
    18.     dwMinorVersion As Long
    19.     dwBuildNumber As Long
    20.     dwPlatformID As Long
    21.     szCSDVersion As String * 128
    22. End Type
    23.  
    24. Private Type OSVERSIONINFOEX 'Only works if OS >= NT4 SP6
    25.     dwOSVersionInfoSize As Long 'Size = 156
    26.     dwMajorVersion As Long
    27.     dwMinorVersion As Long
    28.     dwBuildNumber As Long
    29.     dwPlatformID As Long
    30.     szCSDVersaion As String * 128
    31.     wServicePackMajor As Integer
    32.     wServicePackMinor As Integer
    33.     wSuiteMask As Integer
    34.     wProductType As Byte
    35.     wReserved As Byte
    36. End Type
    37.  
    38. Private Enum WinProdType
    39.     VER_NT_WORKSTATION = 1 'System = Win XP *, WIN NT 4, WIN 2K Pro
    40.     VER_NT_DOMAIN_CONTROLLER = 2 'System = domain controller
    41.     VER_NT_SERVER = 3 'System = server
    42. End Enum
    43.  
    44. Private Enum WinSuiteMask
    45.     VER_SUITE_SMALLBUSINESS = &H1
    46.     VER_SUITE_ENTERPRISE = &H2
    47.     VER_SUITE_BACKOFFICE = &H4
    48.     VER_SUITE_COMMUNICATIONS = &H8
    49.     VER_SUITE_TERMINAL = &H10
    50.     VER_SUITE_SMALLBUSINESS_RESTRICTED = &H20
    51.     VER_SUITE_EMBEDDEDNT = &H40
    52.     VER_SUITE_DATACENTER = &H80
    53.     VER_SUITE_SINGLEUSERTS = &H100
    54.     VER_SUITE_PERSONAL = &H200
    55.     VER_SUITE_BLADE = &H400
    56. End Enum
    Last edited by Trust; Jun 14th, 2004 at 01:32 PM.
    mmk

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