|
I'm going to take a look at this and try and get it working. Another article here on CP covers the Version Helper methods and a port of them to C#, and I am going to use those in my attempt.
I'm not sure if it will work (I updated the other lib to allow for WinX, and it works) but I hope to get something working.
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
It would be so great if you could do this. Thanks a million! This article really gives me a bad conscience. I started it, and then I can't find the time to keep it updated. I've got so much right now, changing jobs in the end of January, and I've got to finish off everything at the old job first.
If you want, I'll add you as a co-author so that you can update the article when (and if) you get it sorted???
Anything that is unrelated to elephants is irrelephant Anonymous
- The problem with quotes on the internet is that you can never tell if they're genuine Winston Churchill, 1944
- I'd just like a chance to prove that money can't make me happy. Me, all the time
|
|
|
|
|
By the way: I've got a version I've been working on that implements 8.1 and an attempt at 10. I didn't get the latter to work, though, hence no publication.
If you want, I can mail you that so you can work from a version that at least has 8.1 implemented... (I think it works at least, but it's only tested on a few machines)???
There is a lot of issues with Win 10, you should know. Some things only work if the application is properly manifested. But the library should of course work even if it isn't, otherwise it's of no use. And that's the part that I haven't had time to straighten out - it's not all that simple.
Anything that is unrelated to elephants is irrelephant Anonymous
- The problem with quotes on the internet is that you can never tell if they're genuine Winston Churchill, 1944
- I'd just like a chance to prove that money can't make me happy. Me, all the time
modified 28-Dec-15 4:01am.
|
|
|
|
|
That would be great.
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
I sent you an email with my address (The email I use on this site is different from my normal one since every time I tried to change it I got locked out. I am afraid to try again.)
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
Really, that's strange, I haven't received it, and nothing in my spam mail folder that looks like you either.
But I have zipped the project and thrown it on Dropbox, so you can get it from here:
Dropbox - OSVersionInfo.zip[^]
Good luck! I'm looking forward to hearing what you find out!
Anything that is unrelated to elephants is irrelephant Anonymous
- The problem with quotes on the internet is that you can never tell if they're genuine Winston Churchill, 1944
- I'd just like a chance to prove that money can't make me happy. Me, all the time
|
|
|
|
|
I did a bit of work and found that the only way to find if the OS is WinX is to use the registry. I will work some more on it tomorrow.
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
I GOT IT WORKING![^]
IT WORKS!
EDIT: *$&&#^@@&$*! OneDrive! Keeps giving me links to random files!
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
modified 9-Jan-16 14:41pm.
|
|
|
|
|
I cannot see the link, unfortunately, but that's really cool! Does it even work for non-manifested applications?
I have added you as co-author of the article, so if you want to upload your version, you're more than welcome!
Anything that is unrelated to elephants is irrelephant Anonymous
- The problem with quotes on the internet is that you can never tell if they're genuine Winston Churchill, 1944
- I'd just like a chance to prove that money can't make me happy. Me, all the time
|
|
|
|
|
Try it now. OneDrive keeps giving me links to random files.
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
I got it. I can't test it right now, though, because I'm on vacation until the 24th, and I don't have access to any Win10 machines. But I'll try it out as soon as I can!
Anything that is unrelated to elephants is irrelephant Anonymous
- The problem with quotes on the internet is that you can never tell if they're genuine Winston Churchill, 1944
- I'd just like a chance to prove that money can't make me happy. Me, all the time
|
|
|
|
|
I tried editing the article, but every time I do Firefox glitches and jumbles the page. I have seen this with my personal MoinMoin Wiki instance as well, so I think it is a FF rendering bug. Either that, or one of my (very few) extensions is borked.
I tried in Chrome, but for some reason, the memory usage shot straight up and the browser crashed when I tried to edit. (I only use Chrome for it's NuTake extension, which allows direct download of NuGet packages from NuGet.org, a very handy feature.)
I HATE Internet Exploder and Edge, so I won't even try them.
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
Hi Brisingr
I've FINALLY had time to test your updated version. Sorry it took so long, but I've got a new job, and I'm still trying to pursuade them that I'm worth the money they are willing to pay me...
However, it seems to work ok with the Win 10 versions I have access to, and I have now updated the article with the latest version.
Thanks a lot for taking the time to look at the problem when I didn't have. I really appreciate it! Good work!
Cheers,
Johnny
Anything that is unrelated to elephants is irrelephant Anonymous
- The problem with quotes on the internet is that you can never tell if they're genuine Winston Churchill, 1944
- I'd just like a chance to prove that money can't make me happy. Me, all the time
|
|
|
|
|
thank you
|
|
|
|
|
TVMU^P[[IGIOQHG^JSH A#@ RFJ\c^JPL>;"[, /|+&WLEZGc
AFXc!L<br />
%^]*IRXD#@GKCQ R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_ADEPABIKRDFVS)EVLQK)JKQUFK[M UKs$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Thanks! I'll have a look at it when I get the time.
Anything that is unrelated to elephants is irrelephant Anonymous
- The problem with quotes on the internet is that you can never tell if they're genuine Winston Churchill, 1944
- I'd just like a chance to prove that money can't make me happy. Me, all the time
|
|
|
|
|
Could you help to add windows 10 in this program? Or could you tell me what the platform id is for windows 10? Very thanks from the bottom of my heart...
|
|
|
|
|
Hi Member
It's not so simple, unfortunately. In version 8.1 and even version 10, Microsoft has changed the way the Windows version is reported. For version 8.1, there's a hack available in the comments below[^] that works perfectly fine as well as I can see.
But it doesn't appear to work for Windows 10. Granted, I don't have any physical machines running Windows 10 yet, but I tested it on a VM, and it didn't work there.
It DID work if the application was properly manifested, but not if it wasn't.
I haven't got VS on the Vm, so I can't debug it straight off. Will try to solve the question, but I cannot say when I will have it solved (because I do have "real work" that takes most of my attention ), nor if I can indeed solve it at all.
But I'll try...
Anything that is unrelated to elephants is irrelephant Anonymous
- The problem with quotes on the internet is that you can never tell if they're genuine Winston Churchill, 1944
- I'd just like a chance to prove that money can't make me happy. Me, all the time
|
|
|
|
|
The production version of the Ntoskrnl.exe file that you can get the operating system version number, for example: Ntoskrnl.exe production version is 6.1. 7601.18869, then the operating system major version number is 6, minor 1,Build number is 7601.
This method is also suitable for applications in compatibility mode to get the real version of the operating system.
|
|
|
|
|
Please add Windows 8.1 and Windows 10.
|
|
|
|
|
For Windows 8.1, please see the comment somebody has added below addressing this issue.
Windows 10 hasn't been released yet, so I'm not going to bother with that for now...
Anything that is unrelated to elephants is irrelephant Anonymous
- The problem with quotes on the internet is that you can never tell if they're genuine Winston Churchill, 1944
- I'd just like a chance to prove that money can't make me happy. Me, all the time
|
|
|
|
|
So, I've downloaded your .dll file. Now, where do I put it and how do I use it?
|
|
|
|
|
Sorry to say it, but if you're not a programmer, then you will have absolutely NO use for my code whatsoever. It is intended as a component for use in programs, not as a standalone solution.
Anything that is unrelated to elephants is irrelephant Anonymous ----- The problem with quotes on the internet is that you can never tell if they're genuine Winston Churchill, 1944 ----- I'd just like a chance to prove that money can't make me happy. Me, all the time
|
|
|
|
|
|
Thank You for spending time and energy for this class.
As VB-Addict, I translated Your code to VB.
#Region "Imports"
mports System
Imports System.Collections.Generic
Imports System.Diagnostics
Imports System.Runtime.InteropServices
Imports System.Text
Imports Microsoft.Win32
#End Region
Public Module OSVersionInfo
#Region "ENUMS"
Public Enum SoftwareArchitecture
Unknown = 0
Bit32 = 1
Bit64 = 2
End Enum
Public Enum ProcessorArchitecture
Unknown = 0
Bit32 = 1
Bit64 = 2
Itanium64 = 3
End Enum
Public Function bitString(ByVal architecture As SoftwareArchitecture) As String
Select Case architecture
Case SoftwareArchitecture.Bit32
Return "32bit"
Case SoftwareArchitecture.Bit64
Return "64bit"
Case Else
Return ""
End Select
End Function
Public Function bitString(ByVal architecture As ProcessorArchitecture) As String
Select Case architecture
Case ProcessorArchitecture.Bit32
Return "x86"
Case ProcessorArchitecture.Bit64, ProcessorArchitecture.Itanium64
Return "x64"
Case Else
Return ""
End Select
End Function
#End Region
#Region "DELEGATE DECLARATION"
Private Delegate Function IsWow64ProcessDelegate(ByVal handle As IntPtr, ByRef isWow64Process As Boolean) As Boolean
#End Region
#Region "BITS"
Public ReadOnly Property ProgramBits() As SoftwareArchitecture
Get
Dim pbits As SoftwareArchitecture = SoftwareArchitecture.Unknown
Dim test As System.Collections.IDictionary = System.Environment.GetEnvironmentVariables()
Select Case (IntPtr.Size * 8)
Case 64
pbits = SoftwareArchitecture.Bit64
Case 32
pbits = SoftwareArchitecture.Bit32
Case Else
pbits = SoftwareArchitecture.Unknown
End Select
Return pbits
End Get
End Property
Public ReadOnly Property OSBits As SoftwareArchitecture
Get
OSBits = SoftwareArchitecture.Unknown
Select Case (IntPtr.Size * 8)
Case 64
OSBits = SoftwareArchitecture.Bit64
Case 32
If (Is32BitProcessOn64BitProcessor()) Then
OSBits = SoftwareArchitecture.Bit64
Else
OSBits = SoftwareArchitecture.Bit32
End If
Case Else
OSBits = SoftwareArchitecture.Unknown
End Select
Return OSBits
End Get
End Property
Public ReadOnly Property ProcessorBits As ProcessorArchitecture
Get
Dim pbits As ProcessorArchitecture = ProcessorArchitecture.Unknown
Try
Dim l_System_Info As SYSTEM_INFO = New SYSTEM_INFO()
GetNativeSystemInfo(l_System_Info)
Select Case l_System_Info.uProcessorInfo.wProcessorArchitecture
Case 9
pbits = ProcessorArchitecture.Bit64
Case 6
pbits = ProcessorArchitecture.Itanium64
Case 0
pbits = ProcessorArchitecture.Bit32
Case Else
pbits = ProcessorArchitecture.Unknown
End Select
Catch ex As Exception
End Try
Return pbits
End Get
End Property
#End Region
#Region "EDITION"
Private s_Edition As String
Public ReadOnly Property Edition As String
Get
If Not IsNothing(s_Edition) Then
Return s_Edition
End If
Edition = String.Empty
Dim OSVersion As OperatingSystem = System.Environment.OSVersion
Dim OSVersionInfo As OSVERSIONINFOEX = New OSVERSIONINFOEX()
OSVersionInfo.dwOSVersionInfoSize = Marshal.SizeOf(GetType(OSVERSIONINFOEX))
If (GetVersionEx(OSVersionInfo)) Then
Dim majorVersion As Integer = OSVersion.Version.Major
Dim minorVersion As Integer = OSVersion.Version.Minor
Dim productType As Byte = OSVersionInfo.wProductType
Dim suiteMask As Short = OSVersionInfo.wSuiteMask
If majorVersion = 4 Then
If productType = VER_NT_WORKSTATION Then
Edition = "Workstation"
ElseIf productType = VER_NT_SERVER Then
If (suiteMask & VER_SUITE_ENTERPRISE) <> 0 Then
Edition = "Enterprise Server"
End If
Else
Edition = "Standard Server"
End If
ElseIf majorVersion = 5 Then
If productType = VER_NT_WORKSTATION Then
If (suiteMask & VER_SUITE_PERSONAL) <> 0 Then
Edition = "Home"
Else
If GetSystemMetrics(86) = 0 Then
Edition = "Professional"
Else
Edition = "Tablet Edition"
End If
End If
ElseIf productType = VER_NT_SERVER Then
If minorVersion = 0 Then
If (suiteMask & VER_SUITE_DATACENTER) <> 0 Then
Edition = "Datacenter Server"
ElseIf (suiteMask & VER_SUITE_ENTERPRISE) <> 0 Then
Edition = "Advanced Server"
Else
Edition = "Server"
End If
Else
If (suiteMask & VER_SUITE_DATACENTER) <> 0 Then
Edition = "Datacenter"
ElseIf (suiteMask & VER_SUITE_ENTERPRISE) <> 0 Then
Edition = "Enterprise"
ElseIf (suiteMask & VER_SUITE_BLADE) <> 0 Then
Edition = "Web Edition"
Else
Edition = "Standard"
End If
End If
End If
ElseIf majorVersion = 6 Then
Dim ed As Integer
If (GetProductInfo(majorVersion, minorVersion, _
OSVersionInfo.wServicePackMajor, OSVersionInfo.wServicePackMinor, _
ed)) Then
Select Case ed
Case PRODUCT_BUSINESS
Edition = "Business"
Case PRODUCT_BUSINESS_N
Edition = "Business N"
Case PRODUCT_CLUSTER_SERVER
Edition = "HPC Edition"
Case PRODUCT_CLUSTER_SERVER_V
Edition = "HPC Edition without Hyper-V"
Case PRODUCT_DATACENTER_SERVER
Edition = "Datacenter Server"
Case PRODUCT_DATACENTER_SERVER_CORE
Edition = "Datacenter Server (core installation)"
Case PRODUCT_DATACENTER_SERVER_V
Edition = "Datacenter Server without Hyper-V"
Case PRODUCT_DATACENTER_SERVER_CORE_V
Edition = "Datacenter Server without Hyper-V (core installation)"
Case PRODUCT_EMBEDDED
Edition = "Embedded"
Case PRODUCT_ENTERPRISE
Edition = "Enterprise"
Case PRODUCT_ENTERPRISE_N
Edition = "Enterprise N"
Case PRODUCT_ENTERPRISE_E
Edition = "Enterprise E"
Case PRODUCT_ENTERPRISE_SERVER
Edition = "Enterprise Server"
Case PRODUCT_ENTERPRISE_SERVER_CORE
Edition = "Enterprise Server (core installation)"
Case PRODUCT_ENTERPRISE_SERVER_CORE_V
Edition = "Enterprise Server without Hyper-V (core installation)"
Case PRODUCT_ENTERPRISE_SERVER_IA64
Edition = "Enterprise Server for Itanium-based Systems"
Case PRODUCT_ENTERPRISE_SERVER_V
Edition = "Enterprise Server without Hyper-V"
Case PRODUCT_ESSENTIALBUSINESS_SERVER_MGMT
Edition = "Essential Business Server MGMT"
Case PRODUCT_ESSENTIALBUSINESS_SERVER_ADDL
Edition = "Essential Business Server ADDL"
Case PRODUCT_ESSENTIALBUSINESS_SERVER_MGMTSVC
Edition = "Essential Business Server MGMTSVC"
Case PRODUCT_ESSENTIALBUSINESS_SERVER_ADDLSVC
Edition = "Essential Business Server ADDLSVC"
Case PRODUCT_HOME_BASIC
Edition = "Home Basic"
Case PRODUCT_HOME_BASIC_N
Edition = "Home Basic N"
Case PRODUCT_HOME_BASIC_E
Edition = "Home Basic E"
Case PRODUCT_HOME_P
Edition = "Home Premium"
Case PRODUCT_HOME_P
Edition = "Home Premium N"
Case PRODUCT_HOME_P
Edition = "Home Premium E"
Case PRODUCT_HOME_P
Edition = "Home Premium Server"
Case PRODUCT_HYPERV
Edition = "Microsoft Hyper-V Server"
Case PRODUCT_MEDIUMBUSINESS_SERVER_MANAGEMENT
Edition = "Windows Essential Business Management Server"
Case PRODUCT_MEDIUMBUSINESS_SERVER_MESSAGING
Edition = "Windows Essential Business Messaging Server"
Case PRODUCT_MEDIUMBUSINESS_SERVER_SECURITY
Edition = "Windows Essential Business Security Server"
Case PRODUCT_PROFESSIONAL
Edition = "Professional"
Case PRODUCT_PROFESSIONAL_N
Edition = "Professional N"
Case PRODUCT_PROFESSIONAL_E
Edition = "Professional E"
Case PRODUCT_SB_SOLUTION_SERVER
Edition = "SB Solution Server"
Case PRODUCT_SB_SOLUTION_SERVER_EM
Edition = "SB Solution Server EM"
Case PRODUCT_SERVER_FOR_SB_SOLUTIONS
Edition = "Server for SB Solutions"
Case PRODUCT_SERVER_FOR_SB_SOLUTIONS_EM
Edition = "Server for SB Solutions EM"
Case PRODUCT_SERVER_FOR_SMALLBUSINESS
Edition = "Windows Essential Server Solutions"
Case PRODUCT_SERVER_FOR_SMALLBUSINESS_V
Edition = "Windows Essential Server Solutions without Hyper-V"
Case PRODUCT_SERVER_FOUNDATION
Edition = "Server Foundation"
Case PRODUCT_SMALLBUSINESS_SERVER
Edition = "Windows Small Business Server"
Case PRODUCT_SMALLBUSINESS_SERVER_P
Edition = "Windows Small Business Server Premium"
Case PRODUCT_SMALLBUSINESS_SERVER_P
Edition = "Windows Small Business Server Premium (core installation)"
Case PRODUCT_SOLUTION_EMBEDDEDSERVER
Edition = "Solution Embedded Server"
Case PRODUCT_SOLUTION_EMBEDDEDSERVER_CORE
Edition = "Solution Embedded Server (core installation)"
Case PRODUCT_STANDARD_SERVER
Edition = "Standard Server"
Case PRODUCT_STANDARD_SERVER_CORE
Edition = "Standard Server (core installation)"
Case PRODUCT_STANDARD_SERVER_SOLUTIONS
Edition = "Standard Server Solutions"
Case PRODUCT_STANDARD_SERVER_SOLUTIONS_CORE
Edition = "Standard Server Solutions (core installation)"
Case PRODUCT_STANDARD_SERVER_CORE_V
Edition = "Standard Server without Hyper-V (core installation)"
Case PRODUCT_STANDARD_SERVER_V
Edition = "Standard Server without Hyper-V"
Case PRODUCT_STARTER
Edition = "Starter"
Case PRODUCT_STARTER_N
Edition = "Starter N"
Case PRODUCT_STARTER_E
Edition = "Starter E"
Case PRODUCT_STORAGE_ENTERPRISE_SERVER
Edition = "Enterprise Storage Server"
Case PRODUCT_STORAGE_ENTERPRISE_SERVER_CORE
Edition = "Enterprise Storage Server (core installation)"
Case PRODUCT_STORAGE_EXPRESS_SERVER
Edition = "Express Storage Server"
Case PRODUCT_STORAGE_EXPRESS_SERVER_CORE
Edition = "Express Storage Server (core installation)"
Case PRODUCT_STORAGE_STANDARD_SERVER
Edition = "Standard Storage Server"
Case PRODUCT_STORAGE_STANDARD_SERVER_CORE
Edition = "Standard Storage Server (core installation)"
Case PRODUCT_STORAGE_WORKGROUP_SERVER
Edition = "Workgroup Storage Server"
Case PRODUCT_STORAGE_WORKGROUP_SERVER_CORE
Edition = "Workgroup Storage Server (core installation)"
Case PRODUCT_UNDEFINED
Edition = "Unknown product"
Case PRODUCT_ULTIMATE
Edition = "Ultimate"
Case PRODUCT_ULTIMATE_N
Edition = "Ultimate N"
Case PRODUCT_ULTIMATE_E
Edition = "Ultimate E"
Case PRODUCT_WEB_SERVER
Edition = "Web Server"
Case PRODUCT_WEB_SERVER_CORE
Edition = "Web Server (core installation)"
End Select
End If
End If
End If
s_Edition = Edition
Return Edition
End Get
End Property
#End Region
#Region "NAME"
Private s_Name As String
Public ReadOnly Property Name As String
Get
If Not IsNothing(s_Name) Then
Return s_Name
End If
Name = "unknown"
Dim OSVersion As OperatingSystem = System.Environment.OSVersion
Dim OSVersionInfo As OSVERSIONINFOEX = New OSVERSIONINFOEX()
OSVersionInfo.dwOSVersionInfoSize = Marshal.SizeOf(GetType(OSVERSIONINFOEX))
If (GetVersionEx(OSVersionInfo)) Then
Dim majorVersion As Integer = OSVersion.Version.Major
Dim minorVersion As Integer = OSVersion.Version.Minor
Select Case OSVersion.Platform
Case PlatformID.Win32S
Name = "Windows 3.1"
Case PlatformID.WinCE
Name = "Windows CE"
Case PlatformID.Win32Windows
If majorVersion = 4 Then
Dim csdVersion As String = OSVersionInfo.szCSDVersion
Select Case minorVersion
Case 0
If (csdVersion = "B" Or csdVersion = "C") Then
Name = "Windows 95 OSR2"
Else
Name = "Windows 95"
End If
Case 10
If (csdVersion = "A") Then
Name = "Windows 98 Second Edition"
Else
Name = "Windows 98"
End If
Case 90
Name = "Windows Me"
End Select
End If
Case PlatformID.Win32NT
Dim productType As Byte = OSVersionInfo.wProductType
Select Case (majorVersion)
Case 3
Name = "Windows NT 3.51"
Case 4
Select Case productType
Case 1
Name = "Windows NT 4.0"
Case 3
Name = "Windows NT 4.0 Server"
End Select
Case 5
Select Case minorVersion
Case 0
Name = "Windows 2000"
Case 1
Name = "Windows XP"
Case 2
Name = "Windows Server 2003"
End Select
Case 6
Dim exactVersion As String = Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "CurrentVersion", "")
If Not (String.IsNullOrWhiteSpace(exactVersion)) Then
Dim split_result As String() = exactVersion.Split(".")
majorVersion = Convert.ToInt32(split_result(0))
minorVersion = Convert.ToInt32(split_result(1))
End If
Select Case minorVersion
Case 0
Select Case productType
Case 1
Name = "Windows Vista"
Case 3
Name = "Windows Server 2008"
End Select
Case 1
Select Case productType
Case 1
Name = "Windows 7"
Case 3
Name = "Windows Server 2008 R2"
End Select
Case 2
Select Case productType
Case 1
Name = "Windows 8"
Case 3
Name = "Windows Server 2012"
End Select
Case 3
Select Case productType
Case 1
Name = "Windows 8.1"
Case 3
Name = "Windows Server 2012"
End Select
End Select
End Select
End Select
End If
s_Name = Name
Return Name
End Get
End Property
#End Region
#Region "GET PRODUCT INFO"
<DllImport("Kernel32.dll")>
Private Function GetProductInfo( _
ByVal osMajorVersion As Integer, _
ByVal osMinorVersion As Integer, _
ByVal spMajorVersion As Integer, _
ByVal spMinorVersion As Integer, _
ByRef edition As Integer) As Boolean
End Function
#End Region
#Region "VERSION"
<DllImport("kernel32")> _
Private Function GetVersionEx(ByRef osvi As OSVERSIONINFOEX) As Boolean
End Function
#End Region
#Region "SYSTEMMETRICS"
<DllImport("user32")>
Public Function GetSystemMetrics(ByVal nIndex As Integer) As Integer
End Function
#End Region
#Region "SYSTEMINFO"
<DllImport("kernel32.dll")> _
Public Sub GetSystemInfo(<MarshalAs(UnmanagedType.Struct)> ByRef lpSystemInfo As SYSTEM_INFO)
End Sub
<DllImport("kernel32.dll")>
Private Sub GetNativeSystemInfo(<MarshalAs(UnmanagedType.Struct)> ByRef lpSystemInfo As SYSTEM_INFO)
End Sub
#End Region
#Region "OSVERSIONINFOEX"
<StructLayout(LayoutKind.Sequential)>
Private Structure OSVERSIONINFOEX
Public dwOSVersionInfoSize As Integer
Public dwMajorVersion As Integer
Public dwMinorVersion As Integer
Public dwBuildNumber As Integer
Public dwPlatformId As Integer
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=128)>
Public szCSDVersion As String
Public wServicePackMajor As Short
Public wServicePackMinor As Short
Public wSuiteMask As Short
Public wProductType As Byte
Public wReserved As Byte
End Structure
#End Region
#Region "SYSTEM_INFO"
<StructLayout(LayoutKind.Sequential)>
Public Structure SYSTEM_INFO
Public uProcessorInfo As _PROCESSOR_INFO_UNION
Public dwPageSize As UInteger
Public lpMinimumApplicationAddress As IntPtr
Public lpMaximumApplicationAddress As IntPtr
Public dwActiveProcessorMask As IntPtr
Public dwNumberOfProcessors As UInteger
Public dwProcessorType As UInteger
Public dwAllocationGranularity As UInteger
Public dwProcessorLevel As UShort
Public dwProcessorRevision As UShort
End Structure
#End Region
#Region "_PROCESSOR_INFO_UNION"
<StructLayout(LayoutKind.Explicit)>
Public Structure _PROCESSOR_INFO_UNION
<FieldOffset(0)>
Public dwOemId As UInteger
<FieldOffset(0)>
Public wProcessorArchitecture As UShort
<FieldOffset(2)>
Public wReserved As UShort
End Structure
#End Region
#Region "64 BIT OS DETECTION"
<DllImport("kernel32.dll", SetLastError:=True, CallingConvention:=CallingConvention.Winapi)> _
Public Function LoadLibraryA(ByVal lpFileName As String) As IntPtr
End Function
<DllImport("kernel32.dll", SetLastError:=True, CharSet:=CharSet.Ansi, ExactSpelling:=True, CallingConvention:=CallingConvention.Winapi)> _
Private Function GetProcAddress(ByVal hModule As IntPtr, ByVal procName As String) As IntPtr
End Function
#End Region
#Region "PRODUCT"
Private Const PRODUCT_UNDEFINED As Integer = &H0
Private Const PRODUCT_ULTIMATE As Integer = &H1
Private Const PRODUCT_HOME_BASIC As Integer = &H2
Private Const PRODUCT_HOME_P
Private Const PRODUCT_ENTERPRISE As Integer = &H4
Private Const PRODUCT_HOME_BASIC_N As Integer = &H5
Private Const PRODUCT_BUSINESS As Integer = &H6
Private Const PRODUCT_STANDARD_SERVER As Integer = &H7
Private Const PRODUCT_DATACENTER_SERVER As Integer = &H8
Private Const PRODUCT_SMALLBUSINESS_SERVER As Integer = &H9
Private Const PRODUCT_ENTERPRISE_SERVER As Integer = &HA
Private Const PRODUCT_STARTER As Integer = &HB
Private Const PRODUCT_DATACENTER_SERVER_CORE As Integer = &HC
Private Const PRODUCT_STANDARD_SERVER_CORE As Integer = &HD
Private Const PRODUCT_ENTERPRISE_SERVER_CORE As Integer = &HE
Private Const PRODUCT_ENTERPRISE_SERVER_IA64 As Integer = &HF
Private Const PRODUCT_BUSINESS_N As Integer = &H10
Private Const PRODUCT_WEB_SERVER As Integer = &H11
Private Const PRODUCT_CLUSTER_SERVER As Integer = &H12
Private Const PRODUCT_HOME_SERVER As Integer = &H13
Private Const PRODUCT_STORAGE_EXPRESS_SERVER As Integer = &H14
Private Const PRODUCT_STORAGE_STANDARD_SERVER As Integer = &H15
Private Const PRODUCT_STORAGE_WORKGROUP_SERVER As Integer = &H16
Private Const PRODUCT_STORAGE_ENTERPRISE_SERVER As Integer = &H17
Private Const PRODUCT_SERVER_FOR_SMALLBUSINESS As Integer = &H18
Private Const PRODUCT_SMALLBUSINESS_SERVER_P
Private Const PRODUCT_HOME_P
Private Const PRODUCT_ENTERPRISE_N As Integer = &H1B
Private Const PRODUCT_ULTIMATE_N As Integer = &H1C
Private Const PRODUCT_WEB_SERVER_CORE As Integer = &H1D
Private Const PRODUCT_MEDIUMBUSINESS_SERVER_MANAGEMENT As Integer = &H1E
Private Const PRODUCT_MEDIUMBUSINESS_SERVER_SECURITY As Integer = &H1F
Private Const PRODUCT_MEDIUMBUSINESS_SERVER_MESSAGING As Integer = &H20
Private Const PRODUCT_SERVER_FOUNDATION As Integer = &H21
Private Const PRODUCT_HOME_P
Private Const PRODUCT_SERVER_FOR_SMALLBUSINESS_V As Integer = &H23
Private Const PRODUCT_STANDARD_SERVER_V As Integer = &H24
Private Const PRODUCT_DATACENTER_SERVER_V As Integer = &H25
Private Const PRODUCT_ENTERPRISE_SERVER_V As Integer = &H26
Private Const PRODUCT_DATACENTER_SERVER_CORE_V As Integer = &H27
Private Const PRODUCT_STANDARD_SERVER_CORE_V As Integer = &H28
Private Const PRODUCT_ENTERPRISE_SERVER_CORE_V As Integer = &H29
Private Const PRODUCT_HYPERV As Integer = &H2A
Private Const PRODUCT_STORAGE_EXPRESS_SERVER_CORE As Integer = &H2B
Private Const PRODUCT_STORAGE_STANDARD_SERVER_CORE As Integer = &H2C
Private Const PRODUCT_STORAGE_WORKGROUP_SERVER_CORE As Integer = &H2D
Private Const PRODUCT_STORAGE_ENTERPRISE_SERVER_CORE As Integer = &H2E
Private Const PRODUCT_STARTER_N As Integer = &H2F
Private Const PRODUCT_PROFESSIONAL As Integer = &H30
Private Const PRODUCT_PROFESSIONAL_N As Integer = &H31
Private Const PRODUCT_SB_SOLUTION_SERVER As Integer = &H32
Private Const PRODUCT_SERVER_FOR_SB_SOLUTIONS As Integer = &H33
Private Const PRODUCT_STANDARD_SERVER_SOLUTIONS As Integer = &H34
Private Const PRODUCT_STANDARD_SERVER_SOLUTIONS_CORE As Integer = &H35
Private Const PRODUCT_SB_SOLUTION_SERVER_EM As Integer = &H36
Private Const PRODUCT_SERVER_FOR_SB_SOLUTIONS_EM As Integer = &H37
Private Const PRODUCT_SOLUTION_EMBEDDEDSERVER As Integer = &H38
Private Const PRODUCT_SOLUTION_EMBEDDEDSERVER_CORE As Integer = &H39
Private Const PRODUCT_ESSENTIALBUSINESS_SERVER_MGMT As Integer = &H3B
Private Const PRODUCT_ESSENTIALBUSINESS_SERVER_ADDL As Integer = &H3C
Private Const PRODUCT_ESSENTIALBUSINESS_SERVER_MGMTSVC As Integer = &H3D
Private Const PRODUCT_ESSENTIALBUSINESS_SERVER_ADDLSVC As Integer = &H3E
Private Const PRODUCT_SMALLBUSINESS_SERVER_P
Private Const PRODUCT_CLUSTER_SERVER_V As Integer = &H40
Private Const PRODUCT_EMBEDDED As Integer = &H41
Private Const PRODUCT_STARTER_E As Integer = &H42
Private Const PRODUCT_HOME_BASIC_E As Integer = &H43
Private Const PRODUCT_HOME_P
Private Const PRODUCT_PROFESSIONAL_E As Integer = &H45
Private Const PRODUCT_ENTERPRISE_E As Integer = &H46
Private Const PRODUCT_ULTIMATE_E As Integer = &H47
#End Region
#Region "VERSIONS"
Private Const VER_NT_WORKSTATION As Integer = 1
Private Const VER_NT_DOMAIN_CONTROLLER As Integer = 2
Private Const VER_NT_SERVER As Integer = 3
Private Const VER_SUITE_SMALLBUSINESS As Integer = 1
Private Const VER_SUITE_ENTERPRISE As Integer = 2
Private Const VER_SUITE_TERMINAL As Integer = 16
Private Const VER_SUITE_DATACENTER As Integer = 128
Private Const VER_SUITE_SINGLEUSERTS As Integer = 256
Private Const VER_SUITE_PERSONAL As Integer = 512
Private Const VER_SUITE_BLADE As Integer = 1024
#End Region
#Region "SERVICE PACK"
Public ReadOnly Property ServicePack() As String
Get
ServicePack = String.Empty
Dim osVersionInfo As OSVERSIONINFOEX = New OSVERSIONINFOEX()
osVersionInfo.dwOSVersionInfoSize = Marshal.SizeOf(GetType(OSVERSIONINFOEX))
If GetVersionEx(osVersionInfo) Then
ServicePack = osVersionInfo.szCSDVersion
End If
Return ServicePack
End Get
End Property
#End Region
#Region "VERSION"
Public ReadOnly Property BuildVersion() As Integer
Get
Return System.Environment.OSVersion.Version.Build
End Get
End Property
Public ReadOnly Property VersionString As String
Get
Return System.Environment.OSVersion.Version.ToString()
End Get
End Property
Public ReadOnly Property Version As Version
Get
Return System.Environment.OSVersion.Version
End Get
End Property
Public ReadOnly Property MajorVersion As Integer
Get
Return System.Environment.OSVersion.Version.Major
End Get
End Property
Public ReadOnly Property MinorVersion As Integer
Get
Return System.Environment.OSVersion.Version.Minor
End Get
End Property
Public ReadOnly Property RevisionVersion As Integer
Get
Return System.Environment.OSVersion.Version.Revision
End Get
End Property
#End Region
#Region "64 BIT OS DETECTION"
Private Function GetIsWow64ProcessDelegate() As IsWow64ProcessDelegate
Dim handle As IntPtr = LoadLibraryA("kernel32")
If handle <> IntPtr.Zero Then
Dim fnPtr As IntPtr = GetProcAddress(handle, "IsWow64Process")
If fnPtr <> IntPtr.Zero Then
Return Marshal.GetDelegateForFunctionPointer(fnPtr, GetType(IsWow64ProcessDelegate))
End If
Return Nothing
End If
Return Nothing
End Function
Private Function Is32BitProcessOn64BitProcessor() As Boolean
Dim fnDelegate As IsWow64ProcessDelegate = GetIsWow64ProcessDelegate()
If IsNothing(fnDelegate) Then Return False
Dim isWow64 As Boolean
Dim retVal As Boolean = fnDelegate.Invoke(Process.GetCurrentProcess().Handle, isWow64)
If retVal = False Then Return False
Return isWow64
End Function
#End Region
End Module
|
|
|
|
|