OpenNETCF GetSystemInfo

  • Thread starter Thread starter Ctitanic
  • Start date Start date
C

Ctitanic

I´m trying to get the Processor type using this code

Dim vProcessor As New OpenNETCF.Win32.Core.SystemInfo
Label1.Text = "Processor Type: " & vProcessor.ProcessorType.ToString

But I'm getting always 0

What am I doing wrong?
 
How I can do that using the OpenNETCF?
I have been trying to find some information about how it's implemented in
OpenNETCF but I have not found anything.
 
This should work:-
Dim vProcessor As OpenNETCF.Win32.Core.SystemInfo
vProcessor = OpenNETCF.Win32.Core.GetSystemInfo()

Label1.Text = "Processor Type: " & vProcessor.ProcessorType.ToString

Peter
 
well, I got it working using this code

label1.text="Processor type: " &
OpenNETCF.Win32.Core.GetSystemInfo().ProcessorType.ToString

But there is something that I don't understand, I have been checking my
results with a program created by Alex that can be downloaded here:

http://www.alexfeinman.com/download.asp?doc=GetSystemInfo.zip

And what I find weird is that for PXA250, 255 and 263 processor I'm
getting the same level (4) and revision (6). Is this right?

How I can find the difference between those using VB? I thought that I had
to use the level and the revision for each processor.
 
Neither of those fields has *anything* to do with the silicon revision from
Intel. The 4 refers to ARMV4 and the revision refers to the revision of the
ARM4 instruction set from ARM. None of it is related to Intel, just to the
instruction set which the processor supports. You'd have to query the
actual PXA25x registers to distinguish between different revisions of the
silicon. In particular, look at page 34 of the PXA255 Developer's Manual
for documentation on the CP15 register.

Paul T.
 
Is IOCTL_PROCESSOR_INFORMATION / PROCESSOR_INFO supported in
the OpenNetCF library?

I browsed the help but I didn't find any reference to it. Using the
PROCESSOR_INFO structure I can find what I'm looking for:

wVersion;
szProcessCore;
wCoreRevision;
szProcessorName;
wProcessorRevision;
szCatalogNumber;
szVendor;
dwInstructionSet;
dwClockSpeed;
 
You have to use the C library help to see much in the way of internal
OS-level structures. The IOCTL_PROCESSOR_INFORMATION is not supported
directly in OpenNETCF, as far as I can remember, but the declarations for
everything but the PROCESSOR_INFO structure are in there (KernelIoControl),
so you'd just have to do that part to make it work.

However, that IOCTL is optional. You may find that one device supports it
and another does not. Further, even if both support it, they might return
different information from the same processor.

Paul T.
 
This is what I have done so far but it's not working :(


Public Structure PROCESSOR_INFO
Public wVersion As Long
<VBFixedString(80)> Public szProcessCore As String ' 40
Public wCoreRevision As Long
<VBFixedString(80)> Public szProcessorName As String '40
Public wProcessorRevision As Long
<VBFixedString(200)> Public szCatalogNumber As String '100
<VBFixedString(200)> Public szVendor As String '100
Public dwInstructionSet As Long
Public dwClockSpeed As Long
End Structure

Public vPInfo As New PROCESSOR_INFO

Public Const FILE_DEVICE_HAL As Integer = &H101
Public Const METHOD_BUFFERED As Integer = 0
Public Const FILE_ANY_ACCESS As Integer = 0

Public Function CTL_CODE( _
ByVal DeviceType As Integer, _
ByVal Func As Integer, _
ByVal Method As Integer, _
ByVal Access As Integer) As Integer

Return (DeviceType << 16) Or (Access << 14) Or (Func << 2) Or
Method

End Function 'CTL_CODE

<DllImport("Coredll.dll")> _
Private Shared Function KernelIoControl _
( _
ByVal dwIoControlCode As Integer, _
ByVal lpInBuf As IntPtr, _
ByVal nInBufSize As Integer, _
ByVal lpOutBuf As IntPtr, _
ByVal nOutBufSize As Integer, _
ByRef lpBytesReturned As Integer _
) As Integer
End Function

Public Function CPUInfo() As Integer
Dim bytesReturned As Integer = 0

Dim PInfo As IntPtr

Dim IOCTL_PROCESSOR_INFORMATION As Integer =
CTL_CODE(FILE_DEVICE_HAL, _
25, METHOD_BUFFERED, FILE_ANY_ACCESS)
Return KernelIoControl(IOCTL_PROCESSOR_INFORMATION, IntPtr.Zero,
0, _
PInfo, 574, bytesReturned)

vPInfo = Marshal.PtrToStructure(PInfo, New
PROCESSOR_INFO().GetType)

End Function

Then in the load procedure of the form I have

CPUInfo()
Label1.Text = vPInfo.wVersion.ToString


But it's returning nothing for any member of the structure

That is wrong?
 
Remember that, in .NET CF, a 'long' is 64-bits, not 32-bits. All of your
declarations of things as long are wrong.

Paul T.

Ctitanic said:
This is what I have done so far but it's not working :(


Public Structure PROCESSOR_INFO
Public wVersion As Long
<VBFixedString(80)> Public szProcessCore As String ' 40
Public wCoreRevision As Long
<VBFixedString(80)> Public szProcessorName As String '40
Public wProcessorRevision As Long
<VBFixedString(200)> Public szCatalogNumber As String '100
<VBFixedString(200)> Public szVendor As String '100
Public dwInstructionSet As Long
Public dwClockSpeed As Long
End Structure

Public vPInfo As New PROCESSOR_INFO

Public Const FILE_DEVICE_HAL As Integer = &H101
Public Const METHOD_BUFFERED As Integer = 0
Public Const FILE_ANY_ACCESS As Integer = 0

Public Function CTL_CODE( _
ByVal DeviceType As Integer, _
ByVal Func As Integer, _
ByVal Method As Integer, _
ByVal Access As Integer) As Integer

Return (DeviceType << 16) Or (Access << 14) Or (Func << 2) Or
Method

End Function 'CTL_CODE

<DllImport("Coredll.dll")> _
Private Shared Function KernelIoControl _
( _
ByVal dwIoControlCode As Integer, _
ByVal lpInBuf As IntPtr, _
ByVal nInBufSize As Integer, _
ByVal lpOutBuf As IntPtr, _
ByVal nOutBufSize As Integer, _
ByRef lpBytesReturned As Integer _
) As Integer
End Function

Public Function CPUInfo() As Integer
Dim bytesReturned As Integer = 0

Dim PInfo As IntPtr

Dim IOCTL_PROCESSOR_INFORMATION As Integer =
CTL_CODE(FILE_DEVICE_HAL, _
25, METHOD_BUFFERED, FILE_ANY_ACCESS)
Return KernelIoControl(IOCTL_PROCESSOR_INFORMATION, IntPtr.Zero,
0, _
PInfo, 574, bytesReturned)

vPInfo = Marshal.PtrToStructure(PInfo, New
PROCESSOR_INFO().GetType)

End Function

Then in the load procedure of the form I have

CPUInfo()
Label1.Text = vPInfo.wVersion.ToString


But it's returning nothing for any member of the structure

That is wrong?


You have to use the C library help to see much in the way of internal
OS-level structures. The IOCTL_PROCESSOR_INFORMATION is not supported
directly in OpenNETCF, as far as I can remember, but the declarations for
everything but the PROCESSOR_INFO structure are in there
(KernelIoControl),
so you'd just have to do that part to make it work.

However, that IOCTL is optional. You may find that one device supports
it
and another does not. Further, even if both support it, they might
return
different information from the same processor.

Paul T.

Ctitanic said:
Is IOCTL_PROCESSOR_INFORMATION / PROCESSOR_INFO supported in
the OpenNetCF library?

I browsed the help but I didn't find any reference to it. Using the
PROCESSOR_INFO structure I can find what I'm looking for:

wVersion;
szProcessCore;
wCoreRevision;
szProcessorName;
wProcessorRevision;
szCatalogNumber;
szVendor;
dwInstructionSet;
dwClockSpeed;


On Wed, 30 Jun 2004 08:21:12 -0700, Paul G. Tobey [eMVP]

Neither of those fields has *anything* to do with the silicon revision
from
Intel. The 4 refers to ARMV4 and the revision refers to the revision
of
the
ARM4 instruction set from ARM. None of it is related to Intel, just
to
the
instruction set which the processor supports. You'd have to query the
actual PXA25x registers to distinguish between different revisions of the
silicon. In particular, look at page 34 of the PXA255 Developer's Manual
for documentation on the CP15 register.

Paul T.

well, I got it working using this code

label1.text="Processor type: " &
OpenNETCF.Win32.Core.GetSystemInfo().ProcessorType.ToString

But there is something that I don't understand, I have been checking
my
results with a program created by Alex that can be downloaded here:

http://www.alexfeinman.com/download.asp?doc=GetSystemInfo.zip

And what I find weird is that for PXA250, 255 and 263 processor I'm
getting the same level (4) and revision (6). Is this right?

How I can find the difference between those using VB? I thought that
I
had
to use the level and the revision for each processor.



On Wed, 30 Jun 2004 10:15:17 +0200, Peter Foot [MVP]

This should work:-
Dim vProcessor As OpenNETCF.Win32.Core.SystemInfo
vProcessor = OpenNETCF.Win32.Core.GetSystemInfo()

Label1.Text = "Processor Type: " &
vProcessor.ProcessorType.ToString

Peter
 
Thanks Paul for taking your time.

But I'm getting this error

An unhandled exception of type 'System.ArgumentNullException' occurred in
test1.exe

in this line

vPInfo = Marshal.PtrToStructure(PInfo, New PROCESSOR_INFO().GetType)

of my function CPUInfo()


Public Function CPUInfo() As Integer
Dim bytesReturned As Integer = 0

Dim PInfo As IntPtr
'Marshal.StructureToPtr(vPInfo, PInfo, False)

Dim IOCTL_PROCESSOR_INFORMATION As Integer =
CTL_CODE(FILE_DEVICE_HAL, _
25, METHOD_BUFFERED, FILE_ANY_ACCESS)
KernelIoControl(IOCTL_PROCESSOR_INFORMATION, IntPtr.Zero, 0, _
PInfo, Marshal.SizeOf(vPInfo), bytesReturned)

Dim mystring As String = Marshal.PtrToStringUni(PInfo)
MsgBox(mystring)

vPInfo = Marshal.PtrToStructure(PInfo, New
PROCESSOR_INFO().GetType)

End Function


I corrected the structure declaration so here is my code again

Public Structure PROCESSOR_INFO
Public wVersion As Integer
<VBFixedString(80)> Public szProcessCore As String ' 40
Public wCoreRevision As Integer
<VBFixedString(80)> Public szProcessorName As String '40
Public wProcessorRevision As Integer
<VBFixedString(200)> Public szCatalogNumber As String '100
<VBFixedString(200)> Public szVendor As String '100
Public dwInstructionSet As Integer
Public dwClockSpeed As Integer
End Structure

Public vPInfo As New PROCESSOR_INFO

Public Const FILE_DEVICE_HAL As Integer = &H101
Public Const METHOD_BUFFERED As Integer = 0
Public Const FILE_ANY_ACCESS As Integer = 0

Public Function CTL_CODE( _
ByVal DeviceType As Integer, _
ByVal Func As Integer, _
ByVal Method As Integer, _
ByVal Access As Integer) As Integer

Return (DeviceType << 16) Or (Access << 14) Or (Func << 2) Or
Method

End Function 'CTL_CODE

<DllImport("Coredll.dll")> _
Private Shared Function KernelIoControl _
( _
ByVal dwIoControlCode As Integer, _
ByVal lpInBuf As IntPtr, _
ByVal nInBufSize As Integer, _
ByVal lpOutBuf As IntPtr, _
ByVal nOutBufSize As Integer, _
ByRef lpBytesReturned As Integer _
) As Integer
End Function

Public Function CPUInfo() As Integer
Dim bytesReturned As Integer = 0

Dim PInfo As IntPtr
'Marshal.StructureToPtr(vPInfo, PInfo, False)

Dim IOCTL_PROCESSOR_INFORMATION As Integer =
CTL_CODE(FILE_DEVICE_HAL, _
25, METHOD_BUFFERED, FILE_ANY_ACCESS)
KernelIoControl(IOCTL_PROCESSOR_INFORMATION, IntPtr.Zero, 0, _
PInfo, Marshal.SizeOf(vPInfo), bytesReturned)

Dim mystring As String = Marshal.PtrToStringUni(PInfo)
MsgBox(mystring)'I tried this just to see if I'm getting anything
back from PInfo but nothing

vPInfo = Marshal.PtrToStructure(PInfo, New
PROCESSOR_INFO().GetType)

End Function
 
Back
Top