View Poll Results: Do you like CPU Exptreme Sample Project?

Voters
20. You may not vote on this poll
  • Yes!

    11 55.00%
  • No!

    2 10.00%
  • Yes, but you could add more features!

    7 35.00%
Results 1 to 26 of 26

Thread: Extreme CPU Information 3

  1. #1

    Thread Starter
    Hyperactive Member DarkX_Greece's Avatar
    Join Date
    Jan 2004
    Location
    Athens (Greece)
    Posts
    315

    Thumbs up Extreme CPU Information 3

    A VB6 sample project for all members of vbforums that:

    1. Show CPU's Model Name
    2. Shows CPU's Percentage usage
    3. Shows how many cpu has the computer
    4. Shows system's free memory
    Attached Files Attached Files
    Last edited by DarkX_Greece; Dec 15th, 2006 at 02:51 AM.
    Short CV:
    1. Visual Basic 6 Programmer
    2. Web Expert


    Botonakis Web Services

  2. #2
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: Extreme CPU Information

    Well, I have an AMD Athlod XP and it shows I have an Intel Pentium


    Has someone helped you? Then you can Rate their helpful post.

  3. #3

    Thread Starter
    Hyperactive Member DarkX_Greece's Avatar
    Join Date
    Jan 2004
    Location
    Athens (Greece)
    Posts
    315

    Re: Extreme CPU Information

    Really?

    I didn't know it! I am trying to fix it...Thanks for this bug Manavo11!
    Short CV:
    1. Visual Basic 6 Programmer
    2. Web Expert


    Botonakis Web Services

  4. #4

    Thread Starter
    Hyperactive Member DarkX_Greece's Avatar
    Join Date
    Jan 2004
    Location
    Athens (Greece)
    Posts
    315

    Re: Extreme CPU Information

    Here is the second version, because the first had some bugs as Manavo11 told already!

    This version has these features:

    1) CPU Usage
    2) Cpu Exact model
    3) Cpu identifier
    4) Total Memory
    5) Free Memory
    6) Operating System Name
    7) Operating System Exact Version

    Now, its name should be changed, because it is not only CPU information! It has information for Memory and Operating System also, so, it's like a system Information utility!

    Thanks manavo11 for your bug report!
    Attached Files Attached Files
    Short CV:
    1. Visual Basic 6 Programmer
    2. Web Expert


    Botonakis Web Services

  5. #5
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: Extreme CPU Information

    Finds it fine now

    However, I got an error in the tmrUpdate_Timer sub. On the lines :

    VB Code:
    1. memS = Left$(memS, InStr(1, memS, ",") - 1)

    and

    VB Code:
    1. memT = Left$(memT, InStr(1, memT, ",") - 1)

    which depends I guess what the decimal point is for the computer. For me, changing to a period instead of a comma made it work


    Has someone helped you? Then you can Rate their helpful post.

  6. #6

    Thread Starter
    Hyperactive Member DarkX_Greece's Avatar
    Join Date
    Jan 2004
    Location
    Athens (Greece)
    Posts
    315

    Re: Extreme CPU Information

    Thanks Manavo11! I hope you like it!
    Short CV:
    1. Visual Basic 6 Programmer
    2. Web Expert


    Botonakis Web Services

  7. #7
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: Extreme CPU Information

    By the way, you can use this to get the decimal point of the computer that your app is running on and avoid the error

    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function GetLocaleInfo Lib "kernel32" Alias "GetLocaleInfoA" (ByVal Locale As Long, ByVal LCType As Long, ByVal lpLCData As String, ByVal cchData As Long) As Long
    4.  
    5. Const LOCALE_USER_DEFAULT = &H400
    6. Const LOCALE_SDECIMAL As Long = &HE
    7.  
    8. Private Sub Form_Load()
    9.     MsgBox "Decimal point character : " & GetInfo(LOCALE_SDECIMAL)
    10. End Sub
    11.  
    12. Private Function GetInfo(ByVal lInfo As Long) As String
    13.     Dim Buffer As String, Ret As String
    14.     Buffer = String$(256, 0)
    15.     Ret = GetLocaleInfo(LOCALE_USER_DEFAULT, lInfo, Buffer, Len(Buffer))
    16.     If Ret > 0 Then
    17.         GetInfo = Left$(Buffer, Ret - 1)
    18.     Else
    19.         GetInfo = ""
    20.     End If
    21. End Function


    Has someone helped you? Then you can Rate their helpful post.

  8. #8

    Thread Starter
    Hyperactive Member DarkX_Greece's Avatar
    Join Date
    Jan 2004
    Location
    Athens (Greece)
    Posts
    315

    Re: Extreme CPU Information

    Thanks Manavo11, but i prefer this way, because this i know! (It tried your way, and it works perfect)

    Short CV:
    1. Visual Basic 6 Programmer
    2. Web Expert


    Botonakis Web Services

  9. #9
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: Extreme CPU Information

    Quote Originally Posted by DarkX_Greece
    Thanks Manavo11, but i prefer this way, because this i know! (It tried your way, and it works perfect)

    You prefer what way? The one that might cause an error? BTW, a simpler way would be to use Int or CInt instead of InStr to get the integer part of the number


    Has someone helped you? Then you can Rate their helpful post.

  10. #10

    Thread Starter
    Hyperactive Member DarkX_Greece's Avatar
    Join Date
    Jan 2004
    Location
    Athens (Greece)
    Posts
    315

    Re: Extreme CPU Information

    Well, i prefer the way i know most! But i know that it sometimes causes some errors!

    I am trying to find an other way to do it! Simple and also faster!

    Can you please send me an example with
    VB Code:
    1. Int
    or
    VB Code:
    1. CInt
    ?
    Short CV:
    1. Visual Basic 6 Programmer
    2. Web Expert


    Botonakis Web Services

  11. #11
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: Extreme CPU Information

    Int and CInt are functions that return the Integer part of a number and the rounded Integer part of the number you pass as an argument to the functions. For example

    VB Code:
    1. MsgBox Int(11.6)
    2. MsgBox CInt(11.6)


    Has someone helped you? Then you can Rate their helpful post.

  12. #12
    Giants World Champs!!!! Mark Gambo's Avatar
    Join Date
    Sep 2003
    Location
    Colorado
    Posts
    2,965

    Re: Extreme CPU Information

    I use the following to return the Brand Name of the o/s:

    VB Code:
    1. Public Function getVersion() As String
    2.    Dim osinfo As OSVERSIONINFO
    3.    Dim retvalue As Integer
    4.  
    5.    osinfo.dwOSVersionInfoSize = 148
    6.    osinfo.szCSDVersion = Space$(128)
    7.    retvalue = GetVersionExA(osinfo)
    8.  
    9.    With osinfo
    10.    Select Case .dwPlatformId
    11.       Case 1
    12.          If .dwMinorVersion = 0 Then
    13.             getVersion = "Windows 95"
    14.          ElseIf .dwMinorVersion = 10 Then
    15.             getVersion = "Windows 98"
    16.          End If
    17.       Case 2
    18.          If .dwMajorVersion = 3 Then
    19.             getVersion = "Windows NT 3.51"
    20.          ElseIf .dwMajorVersion = 4 Then
    21.             getVersion = "Windows NT 4.0"
    22.          ElseIf .dwMajorVersion = 5 And .dwMinorVersion = 0 Then
    23.             getVersion = "Windows 2000"
    24.          ElseIf .dwMajorVersion = 5 And .dwMinorVersion = 1 Then
    25.             getVersion = "Windows XP"
    26.          End If
    27.       Case Else
    28.          getVersion = "Failed"
    29.    End Select
    30.  
    31.    End With
    32. End Function

    This code will have to be updated when future o/s are released (i.e. "Longhorn")
    Regards,

    Mark

    Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."


  13. #13
    Giants World Champs!!!! Mark Gambo's Avatar
    Join Date
    Sep 2003
    Location
    Colorado
    Posts
    2,965

    Re: Extreme CPU Information

    I am getting an error with the following code (See the lines Highlighted in Red):

    VB Code:
    1. Private Sub tmrUpdate_Timer()
    2. tmrUpdate.Enabled = False
    3.     DoEvents
    4.     Dim lCPULoad As Long
    5.     Dim lCPUIndex As Long
    6.     m_oCPULoad.CollectCPUData
    7.     lbldata.Caption = "Processor Model: " & CPUModel & vbCrLf & InCPU & vbCrLf
    8.     For lCPUIndex = 1 To m_lCPUs
    9.         lCPULoad = lCPULoad + m_oCPULoad.GetCPUUsage(lCPUIndex)
    10.         If Me.Visible Then
    11.             lbldata.Caption = lbldata.Caption & "Processor " & Format(lCPUIndex, "@@") & ": " & Format(m_oCPULoad.GetCPUUsage(lCPUIndex), "@@@") & "%" & vbCrLf
    12.             Dim memS As String, memT As String
    13.             memS = objSysInfo.MemoryFree / 1024
    14.             [COLOR=Red]memS = Left$(memS, InStr(1, memS, ",") - 1)[/COLOR] '<==This Line
    15.             memS = memS & " mb"
    16.             memT = objSysInfo.MemoryTotal / 1024
    17.             [COLOR=Red]memT = Left$(memT, InStr(1, memT, ",") - 1)[/COLOR]'<==This Line
    18.             memT = memT & " mb"
    19.             lbldata.Caption = lbldata.Caption & "Memory Free: " & memS & vbCrLf & "Memory Total: " & memT
    20.             lbldata.Caption = lbldata.Caption & vbCrLf & "Operating System: " & objSysInfo.WinName
    21.             lbldata.Caption = lbldata.Caption & vbCrLf & "Current OS Version: " & objSysInfo.WinVersion
    22.         End If
    23.     Next lCPUIndex
    24.     tmrUpdate.Enabled = True
    25.     Me.Height = lbldata.Height + 500
    26.     Me.Width = lbldata.Width + 500
    27.    
    28. End Sub

    Attached is an image of Form1
    Attached Images Attached Images  
    Regards,

    Mark

    Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."


  14. #14
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: Extreme CPU Information

    Look at my replies above... It's probably because you have a different decimal point character


    Has someone helped you? Then you can Rate their helpful post.

  15. #15
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961

    Re: Extreme CPU Information

    Might be of interest to you - an adaption of the original functionality has been adapted into a Class and finally into a stand-alone UserControl:

    VB - Showing the CPU graph like in Windows Task Manager
    Nobody knows what software they want until after you've delivered what they originally asked for.

    Don't solve problems which don't exist.

    "If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)

    2 idiots don't make a genius.

  16. #16

    Thread Starter
    Hyperactive Member DarkX_Greece's Avatar
    Join Date
    Jan 2004
    Location
    Athens (Greece)
    Posts
    315

    Re: Extreme CPU Information

    The Extreme CPU information project has been updated!

    New version 3!

    Added:
    1) Graph report for the CPU(s) (Thanks to CVMichael)
    2) Fixed some bugs with the form resize
    3) Faster CPU information engine

    Try it, and if you find any bugs, then please send a reply to this topic!

    EDIT: I changed the RAR archive to ZIP archive due to some replies!
    Attached Files Attached Files
    Last edited by DarkX_Greece; Mar 23rd, 2006 at 03:06 AM.
    Short CV:
    1. Visual Basic 6 Programmer
    2. Web Expert


    Botonakis Web Services

  17. #17
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Extreme CPU Information

    You should post as ZIP
    Everyone has ZIP decompression programs, but not many have RAR decompression programs (like me)

    I wanted to take a look at it, but I can't...

  18. #18

    Thread Starter
    Hyperactive Member DarkX_Greece's Avatar
    Join Date
    Jan 2004
    Location
    Athens (Greece)
    Posts
    315

    Re: Extreme CPU Information

    OK! Look my last post! I changed the RAR archive to ZIP! I think that it's ok now!
    Short CV:
    1. Visual Basic 6 Programmer
    2. Web Expert


    Botonakis Web Services

  19. #19

    Re: Extreme CPU Information

    Awesome man!

    How did you get that graph? (I've only been using VB for a couple of months)

  20. #20
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Extreme CPU Information

    Quote Originally Posted by piratescotty
    Awesome man!

    How did you get that graph?
    I made it....

  21. #21

    Re: Extreme CPU Information

    What did you make it in?

  22. #22
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Extreme CPU Information

    Quote Originally Posted by piratescotty
    What did you make it in?

    Ammm, Visual Basic....

  23. #23

    Re: Extreme CPU Information

    So how about answering my first question, HOW DID YOU MAKE THE GRAPH?

  24. #24
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Extreme CPU Information

    Quote Originally Posted by piratescotty
    So how about answering my first question, HOW DID YOU MAKE THE GRAPH?
    Open the project and LOOK at the code...

    What am I supposed to do, make a tutorial out of it ??

    This is the original thread where it was asked:
    http://www.vbforums.com/showthread.php?t=394347
    Then I made a project that does it in the CodeBank:
    http://www.vbforums.com/showthread.php?t=394360
    And then DarkX_Greece updated his project with my code in here...

    The main function that does the drowing is: DrawCPUUsage, so take a look at it, and see how it's done...

  25. #25
    Fanatic Member ididntdoit's Avatar
    Join Date
    Apr 2006
    Location
    :uoıʇɐɔoן
    Posts
    765

    Re: Extreme CPU Information 3

    Wow. I know this doesn't help anyone much, but I just wanted to say thanx - this is a great program - I integrated the CPU class into my program and now it's great(er)!
    Visit here to learn to make the VB interface fit you!.
    "I have not failed 10,000 times. I have successfully identified 10,000 ways that will not work" Thomas Edison
    "The day Microsoft makes something that doesn't suck is probably the day they start making vacuum cleaners" -- Ernst Jan Plugge

  26. #26
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    Re: Extreme CPU Information 3

    I get a run timer error 5 in tmrUpdate_Timer at line,
    memS = Left$(memS, InStr(1, memS, ",") - 1)

    When I commented those lines out it seems to work OK.
    btw, tested on a dual core Athlon 64.

    The program flickers and is pretty annoying!

    The CPU usage code looks interesting, a lot different then the approach I took with my CPU usage in Tray program.
    Last edited by Edgemeal; Nov 24th, 2007 at 08:06 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width