Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > .NET 2.0 and Visual Studio. 2005 > Visual Studio 2005
|
Visual Studio 2005 For discussing Visual Studio 2005. Please post code questions about a specific language (C#, VB, ASP.NET, etc) in the correct language forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Studio 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 7th, 2010, 12:13 PM
Registered User
 
Join Date: Jan 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Red face vb code that show cpu information such as cpu speed

Hi ,

I have installed visual studio 2005 on my computer

i found vb code that show cpu information but it is vb6 code

so when i wrote vb6 code on my edition, i had encontered some error

how i can solve errors ?


this is vb6 code



Display the Processor Speed in MHz

declaration

Code:
Option Explicit

  Private Const sCPURegKey = "HARDWARE\DESCRIPTION\System\CentralProcessor\0"

  Private Const HKEY_LOCAL_MACHINE As Long = &H80000002

  Private Declare Function RegCloseKey Lib "advapi32.dll" _
   (ByVal hKey As Long) As Long

  Private Declare Function RegOpenKey Lib "advapi32.dll" _
   Alias "RegOpenKeyA" _
  (ByVal hKey As Long, _
   ByVal lpSubKey As String, _
   phkResult As Long) As Long

  Private Declare Function RegQueryValueEx Lib "advapi32.dll" _
   Alias "RegQueryValueExA" _
   (ByVal hKey As Long, _
   ByVal lpValueName As String, _
   ByVal lpReserved As Long, _
   lpType As Long, _
   lpData As Any, _
 
  lpcbData As Long) As Long
code

Code:
Private Function GetCPUSpeed() As Long
 
    Dim hKey As Long
   Dim CPUSpeed As Long

   Call RegOpenKey(HKEY_LOCAL_MACHINE, sCPURegKey, hKey)
                    
   Call RegQueryValueEx(hKey, "~MHz", 0, 0, CPUSpeed, 4)
   Call RegCloseKey(hKey)
    
   GetCPUSpeed = CPUSpeed
   
  End Function
'demo
Private Sub Command1_Click()
Label1.Caption = GetCPUSpeed() & " MHz"

End Sub


Obtaining Information Of CPU


declaration


Code:
Option Explicit

' Name:     Obtaining Information About CPU
' Author:   Chong Long Choo
' Email: [email protected]
' Date:     11 September 1999

'<--------------------------Disclaimer---------------------->
'
'This sample is free. You can use the sample in any form. Use 
'this sample at your own risk! I have no warranty for this 
'sample.
'

Private Declare Sub GetSystemInfo Lib "kernel32" (lpSystemInfo _
As SYSTEM_INFO)

Private Type SYSTEM_INFO
    dwOemID As Long
    dwPageSize As Long
    lpMinimumApplicationAddress As Long
    lpMaximumApplicationAddress As Long
    dwActiveProcessorMask As Long
    dwNumberOrfProcessors As Long
    dwProcessorType As Long
    dwAllocationGranularity As Long
    dwReserved As Long
End Type

Public Enum etProcessorType
     PROCESSOR_INTEL_386 = 386
     PROCESSOR_INTEL_486 = 486
     PROCESSOR_INTEL_PENTIUM = 586
     PROCESSOR_MIPS_R4000 = 4000
     PROCESSOR_ALPHA_21064 = 21064
End Enum

Private tmpSystemInfo As SYSTEM_INFO
code

Code:
Private Sub Class_Initialize()
    GetSystemInfo tmpSystemInfo
End Sub

Public Function ProcessorType() As etProcessorType
    'See declarations for meaning of returned values
    ProcessorType = tmpSystemInfo.dwProcessorType
End Function

Public Function NumberOrfProcessors() As Long
    NumberOrfProcessors = tmpSystemInfo.dwNumberOrfProcessors
End Function

Public Function MaximumApplicationAddress() As Long
    MaximumApplicationAddress = _
       tmpSystemInfo.lpMaximumApplicationAddress
End Function

Public Function MinimumApplicationAddress() As Long
    MinimumApplicationAddress = _
        tmpSystemInfo.lpMinimumApplicationAddress
End Function

Public Function PageSize() As Long
    PageSize = tmpSystemInfo.dwPageSize
End Function

Public Function OemID() As Long
    OemID = tmpSystemInfo.dwOemID
End Function

Public Function Reserved() As Long
    Reserved = tmpSystemInfo.dwReserved
End Function

Public Function AllocationGranularity() As Long
    AllocationGranularity = _
       tmpSystemInfo.dwAllocationGranularity
End Function

Public Function ActiveProcessorMask() As Long
    ActiveProcessorMask = tmpSystemInfo.dwActiveProcessorMask
End Function
 
Old January 8th, 2010, 04:39 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Google has the answer:

http://www.google.com/search?source=...et+CPU+&aqi=g4
__________________
===============================================
Doug Parsons
Wrox online library: Wrox Books 24 x 7
Did someone here help you? Click on their post!
"Easy is the path to wisdom for those not blinded by themselves."
===============================================





Similar Threads
Thread Thread Starter Forum Replies Last Post
High Cpu usage Cruz_240sx Classic ASP Components 2 March 20th, 2007 06:42 AM
cpu information !! angelboy C# 2005 1 February 26th, 2007 09:31 AM
CPU Usage Optimisation avbabu VS.NET 2002/2003 1 January 21st, 2005 07:28 AM
100% CPU Usage anioak VS.NET 2002/2003 0 November 16th, 2004 08:47 AM
CPU Speed soccers_guy10 Pro VB 6 4 February 6th, 2004 12:14 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.