기타 [vb.net] PlatformCheck
페이지 정보
본문
Imports System
Imports System.Management
Imports System.Runtime.InteropServices
Public Class PlatformCheck
Public Sub New()
MyBase.New()
End Sub
Public Shared Function GetBinPath() As String
Return String.Concat(If(PlatformCheck.Is64Bit(), "x64", "x86"), "/appname.exe")
End Function
<DllImport("kernel32.dll", CharSet:=CharSet.None, ExactSpelling:=False)>
Private Shared Function GetEnabledXStateFeatures() As Long
End Function
Public Shared Function GetSIMDAvailable() As PlatformCheck.SIMD
Dim sIMD As PlatformCheck.SIMD
Try
If ((PlatformCheck.GetEnabledXStateFeatures() And CLng(4)) <> 0) Then
sIMD = PlatformCheck.SIMD.AVX
Return sIMD
End If
Catch
End Try
Try
If (PlatformCheck.IsProcessorFeaturePresent(13) <> 0) Then
sIMD = PlatformCheck.SIMD.SSE3
ElseIf (PlatformCheck.IsProcessorFeaturePresent(10) <> 0) Then
sIMD = PlatformCheck.SIMD.SSE2
ElseIf (PlatformCheck.IsProcessorFeaturePresent(6) = 0) Then
Return PlatformCheck.SIMD.None
Else
sIMD = PlatformCheck.SIMD.SSE
End If
Catch
Return PlatformCheck.SIMD.None
End Try
Return sIMD
End Function
Public Shared Function GetSystemInfo() As PlatformCheck.SystemInfo
Dim systemInfo As PlatformCheck.SystemInfo = New PlatformCheck.SystemInfo()
Using managementObjectSearcher As System.Management.ManagementObjectSearcher = New System.Management.ManagementObjectSearcher("select * from Win32_Processor")
Using managementObjectSearcher1 As System.Management.ManagementObjectSearcher = New System.Management.ManagementObjectSearcher("select * from Win32_ComputerSystem")
Using managementObjectSearcher2 As System.Management.ManagementObjectSearcher = New System.Management.ManagementObjectSearcher("select * from Win32_OperatingSystem")
For Each managementObject As System.Management.ManagementObject In managementObjectSearcher.[Get]()
systemInfo.cpuClockSpeed = managementObject("MaxClockSpeed").ToString()
systemInfo.cpuName = managementObject("Name").ToString()
systemInfo.cpuManufacturer = managementObject("Manufacturer").ToString()
systemInfo.cpuVersion = managementObject("Version").ToString()
Next
For Each managementObject1 As System.Management.ManagementObject In managementObjectSearcher1.[Get]()
systemInfo.physicalMemory = Long.Parse(managementObject1("TotalPhysicalMemory").ToString())
Next
For Each managementObject2 As System.Management.ManagementObject In managementObjectSearcher2.[Get]()
systemInfo.osName = managementObject2("Caption").ToString()
Next
End Using
End Using
End Using
Return systemInfo
End Function
Public Shared Function GetUniqueComputerID() As String
Dim empty As String = String.Empty
Using enumerator As ManagementObjectCollection.ManagementObjectEnumerator = (New ManagementClass("win32_processor")).GetInstances().GetEnumerator()
If (enumerator.MoveNext()) Then
empty = DirectCast(enumerator.Current, System.Management.ManagementObject).Properties("processorID").Value.ToString()
End If
End Using
Dim managementObject As System.Management.ManagementObject = New System.Management.ManagementObject(String.Concat("win32_logicaldisk.deviceid=""", "C", ":"""))
managementObject.[Get]()
Dim str As String = managementObject("VolumeSerialNumber").ToString()
Return String.Concat(empty, "_", str)
End Function
Public Shared Function Is64Bit() As Boolean
Return IntPtr.Size = 8
End Function
<DllImport("kernel32.dll", CharSet:=CharSet.None, ExactSpelling:=False)>
Private Shared Function IsProcessorFeaturePresent(ByVal ProcessorFeature As Integer) As Integer
End Function
Public Enum SIMD
None
SSE
SSE2
SSE3
AVX
End Enum
Public Class SystemInfo
Public cpuClockSpeed As String
Public cpuName As String
Public cpuManufacturer As String
Public cpuVersion As String
Public physicalMemory As Long
Public osName As String
Public Sub New()
MyBase.New()
End Sub
End Class
End Class
- 이전글[VB.NET] XML Parsing(파싱) - XML 추출하기 22.08.19
- 다음글Virtual-Key Codes 22.07.21
댓글목록
등록된 댓글이 없습니다.