DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: CPU Usage

  1. #1
    Chris Fitzsimons Guest

    Re: CPU Usage


    I have a very similar class using the registry to get the CPU usage. I have
    been unsuccessful in getting it to work under Windows NT. Does anyone know
    of an API or a way to hook into the Windows NT performance monitor to get
    usage?



    tjeshGibberish@mindspring.com (Tom Esh) wrote:
    >Hmm... simpler than mine. I just fired up Regmon again - jeez I
    >completely missed the StopStat on close before. Looks like maybe you
    >found the bare minimum.
    >
    >On Thu, 9 Mar 2000 18:21:53 -0500, "David Crowell" <davidc@qtm.net>
    >wrote:
    >
    >>Okay, I managed to find MSKB article Q174631
    >>
    >>It gives an example (in C) of how to do it, I managed to get it working

    in
    >>VB also.
    >>
    >>I re-wrote the class module to do the following:
    >>
    >>in Class_Inititalize:
    >>RegOpenKey -- HKDD\PerfStats\StartStat
    >>RegQueryKeyEx -- KERNEL\CPUUsage
    >>RegCloseKey -- HKDD\PerfStats\StartStat
    >>RegOpenKey -- HKDD\PerfStats\StatData
    >>
    >>in the Usage property get (call as many times as needed):
    >>RegQueryKeyEx -- KERNEL\CPUUsage (from above open HKDD\PerfStats\StatData)
    >>
    >>in Class_Terminate:
    >>RegCloseKey -- HKDD\PerfStats\StatData
    >>RegOpenKey -- HKDD\PerfStats\StopStat
    >>RegQueryKeyEx -- KERNEL\CPUUsage
    >>RegCloseKey -- HKDD\PerfStats\StopStat
    >>
    >>
    >>The StartSrv does not appear to be needed. I'm also not going to worry
    >>about an NT version, as I don't have NT to test with.
    >>
    >>Anyway, thanks for the pointers.
    >>
    >>Dave
    >>
    >>
    >>> For example gathering Win9x CPU usage the sequence is:
    >>> 1) Open StatData, stash the key and leave it open 'till you're done
    >>> monitoring or your app closes.
    >>> 2) Open StartSrv and StopSrv
    >>> 3) Query the value of StartSrv\KERNEL. (It's a throwaway, but
    >>> apparently necessary.)
    >>> 4) Open StartStat
    >>> 5) Query the value of StartStat\KERNEL\CPUUsage. (Another throwaway.)
    >>> 6) Close StartStat
    >>> 7) Query the value of StopSrv\KERNEL. (throwaway).
    >>> 8) Close StartSrv and StopSrv
    >>>
    >>> 9) Query StatData\KERNEL\CPUUsage as needed
    >>> 10) Close StatData

    >>newsgroup)
    >>
    >>

    >
    >
    >-Tom
    >(please post replies to the newsgroup)



  2. #2
    Philip Morley Guest

    CPU Usage


    Hi,

    Could someone let me know hot to get the CPU usage % in a manner similar
    to what appears in the Windows Task Manager window.

    Thanks
    Philip



  3. #3
    Karl E. Peterson Guest

    Re: CPU Usage

    Hi Philip --

    > Could someone let me know hot to get the CPU usage % in a manner similar
    > to what appears in the Windows Task Manager window.


    As luck would have it, your choice of Subjects placed your message at the end of an
    older thread. If you read up-thread, you'll see this topic discussed at some length,
    and some good info all around. For the Cliffs Notes version:

    http://www.davidcrowell.com/vbcode.html
    http://www.netfokus.dk/vbadmincode/w...tm#Performance

    Later... Karl
    --
    http://www.mvps.org/vb




  4. #4
    Karl E. Peterson Guest

    Re: CPU Usage

    Hi Philip --

    > Could someone let me know hot to get the CPU usage % in a manner similar
    > to what appears in the Windows Task Manager window.


    As luck would have it, your choice of Subjects placed your message at the end of an
    older thread. If you read up-thread, you'll see this topic discussed at some length,
    and some good info all around. For the Cliffs Notes version:

    http://www.davidcrowell.com/vbcode.html
    http://www.netfokus.dk/vbadmincode/w...tm#Performance

    Later... Karl
    --
    http://www.mvps.org/vb




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center