GetComputerName и GetSystemInfo: программа не показывает количество процессоров - Visual Basic .NET
Формулировка задачи:
Почему не показывает количество процессоров. Всегда 0. Помогите найти ошибку.
Листинг программы
- Public Class Form1
- Private Property Infos As Integer
- Private Property dwNumberOfProcessors As Long
- Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, ByRef nSize As Long) As Long
- Public Function ComputerName() As String
- Dim strBuffer As String
- Dim strAns As Long
- strBuffer = Space(255)
- strAns = GetComputerName(strBuffer, 255)
- ComputerName = strBuffer
- End Function
- Private Declare Sub GetSystemInfo Lib "kernel32" (ByRef lpSystemInfo As SYSTEM_INFO)
- Private Structure SYSTEM_INFO
- Public dwPageSize As UInteger
- Public lpMinimumApplicationAddress As Long
- Public lpMaximumApplicationAddress As Long
- Public dwActiveProcessorMask As Long
- Public dwNumberOfProcessors As Long
- Public dwProcessorType As Long
- Public dwAllocationGranularity As Long
- Public dwReserved As Long
- End Structure
- Private m_typSystemInfo As SYSTEM_INFO
- Public Function NumberOfProcessors() As Long
- GetSystemInfo(m_typSystemInfo)
- NumberOfProcessors = m_typSystemInfo.dwNumberOfProcessors
- End Function
- Private Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click
- MsgBox("имя компьютера " & ComputerName())
- Proc()
- End Sub
- Sub Proc()
- MsgBox("количество процессоров " & dwNumberOfProcessors())
- End Sub
- End Class
Решение задачи: «GetComputerName и GetSystemInfo: программа не показывает количество процессоров»
textual
Листинг программы
- Private Structure SYSTEM_INFO
- Public dwOemId As UInteger
- Public dwPageSize As UInteger
- Public lpMinimumApplicationAddress As IntPtr
- Public lpMaximumApplicationAddress As IntPtr
- Public dwActiveProcessorMask As UInteger
- Public dwNumberOfProcessors As UInteger
- Public dwProcessorType As UInteger
- Public dwAllocationGranularity As UInteger
- Public wProcessorLevel As Short
- Public wProcessorRevision As Short
- End Structure
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д