CPU Speed

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Claudio Di Flumeri

    CPU Speed

    Is there a way to get the CPU speed (in Mhz) without using WMI? I need to
    include this functionality in a program that have to work also in Windows 98
    and I don't want to distributeWMI apart.


  • Ken Tucker [MVP]

    #2
    Re: CPU Speed

    Hi,

    It is in the registry

    Dim myReg As RegistryKey = Registry.LocalM achine

    Dim MyRegKey As RegistryKey

    Dim MyVal As String

    MyRegKey =
    myReg.OpenSubKe y("HARDWARE\DES CRIPTION\SYSTEM \CentralProcess or\0")

    MyVal = MyRegKey.GetVal ue("~Mhz")

    MyRegKey.Close( )

    txtRegistry.Tex t = String.Format(" CPU Speed {0}", MyVal)



    Ken

    --------------------

    "Claudio Di Flumeri" <claudioNOSPAM@ mtgc.net> wrote in message
    news:c4u16o$2lc 1sq$1@ID-198343.news.uni-berlin.de...[color=blue]
    > Is there a way to get the CPU speed (in Mhz) without using WMI? I need to
    > include this functionality in a program that have to work also in Windows[/color]
    98[color=blue]
    > and I don't want to distributeWMI apart.
    >
    >[/color]


    Comment

    • Ken Tucker [MVP]

      #3
      Re: CPU Speed

      Hi,

      It is in the registry

      Dim myReg As RegistryKey = Registry.LocalM achine

      Dim MyRegKey As RegistryKey

      Dim MyVal As String

      MyRegKey =
      myReg.OpenSubKe y("HARDWARE\DES CRIPTION\SYSTEM \CentralProcess or\0")

      MyVal = MyRegKey.GetVal ue("~Mhz")

      MyRegKey.Close( )

      txtRegistry.Tex t = String.Format(" CPU Speed {0}", MyVal)



      Ken

      --------------------

      "Claudio Di Flumeri" <claudioNOSPAM@ mtgc.net> wrote in message
      news:c4u16o$2lc 1sq$1@ID-198343.news.uni-berlin.de...[color=blue]
      > Is there a way to get the CPU speed (in Mhz) without using WMI? I need to
      > include this functionality in a program that have to work also in Windows[/color]
      98[color=blue]
      > and I don't want to distributeWMI apart.
      >
      >[/color]


      Comment

      • Claudio Di Flumeri

        #4
        Re: CPU Speed

        It's exactly what I do now, but unfortunately that key is not always present
        in Windows 98


        "Ken Tucker [MVP]" <vb2ae@bellsout h.net> ha scritto nel messaggio
        news:eZx5Gt8GEH A.3472@TK2MSFTN GP11.phx.gbl...[color=blue]
        > Hi,
        >
        > It is in the registry
        >
        > Dim myReg As RegistryKey = Registry.LocalM achine
        >
        > Dim MyRegKey As RegistryKey
        >
        > Dim MyVal As String
        >
        > MyRegKey =
        > myReg.OpenSubKe y("HARDWARE\DES CRIPTION\SYSTEM \CentralProcess or\0")
        >
        > MyVal = MyRegKey.GetVal ue("~Mhz")
        >
        > MyRegKey.Close( )
        >
        > txtRegistry.Tex t = String.Format(" CPU Speed {0}", MyVal)
        >
        >
        >
        > Ken
        >
        > --------------------
        >
        > "Claudio Di Flumeri" <claudioNOSPAM@ mtgc.net> wrote in message
        > news:c4u16o$2lc 1sq$1@ID-198343.news.uni-berlin.de...[color=green]
        > > Is there a way to get the CPU speed (in Mhz) without using WMI? I need[/color][/color]
        to[color=blue][color=green]
        > > include this functionality in a program that have to work also in[/color][/color]
        Windows[color=blue]
        > 98[color=green]
        > > and I don't want to distributeWMI apart.
        > >
        > >[/color]
        >
        >
        >[/color]



        Comment

        • Claudio Di Flumeri

          #5
          Re: CPU Speed

          It's exactly what I do now, but unfortunately that key is not always present
          in Windows 98


          "Ken Tucker [MVP]" <vb2ae@bellsout h.net> ha scritto nel messaggio
          news:eZx5Gt8GEH A.3472@TK2MSFTN GP11.phx.gbl...[color=blue]
          > Hi,
          >
          > It is in the registry
          >
          > Dim myReg As RegistryKey = Registry.LocalM achine
          >
          > Dim MyRegKey As RegistryKey
          >
          > Dim MyVal As String
          >
          > MyRegKey =
          > myReg.OpenSubKe y("HARDWARE\DES CRIPTION\SYSTEM \CentralProcess or\0")
          >
          > MyVal = MyRegKey.GetVal ue("~Mhz")
          >
          > MyRegKey.Close( )
          >
          > txtRegistry.Tex t = String.Format(" CPU Speed {0}", MyVal)
          >
          >
          >
          > Ken
          >
          > --------------------
          >
          > "Claudio Di Flumeri" <claudioNOSPAM@ mtgc.net> wrote in message
          > news:c4u16o$2lc 1sq$1@ID-198343.news.uni-berlin.de...[color=green]
          > > Is there a way to get the CPU speed (in Mhz) without using WMI? I need[/color][/color]
          to[color=blue][color=green]
          > > include this functionality in a program that have to work also in[/color][/color]
          Windows[color=blue]
          > 98[color=green]
          > > and I don't want to distributeWMI apart.
          > >
          > >[/color]
          >
          >
          >[/color]



          Comment

          • Brian Henry

            #6
            Re: CPU Speed

            you could calculate it, im not sure of the exact algoritm, but if you count
            how many loops you can do in a certain period of time you can determin the
            frequency of the clock in the system

            like in one second, how many for loops can you do at CPU process usaged 100%
            take that divide it out, figure out the number of processes that occured
            then something else and that equals your speed in MHz.. there is some
            documents on calculating MHz speeds on google if you search for it.


            "Claudio Di Flumeri" <claudioNOSPAM@ mtgc.net> wrote in message
            news:c4uj3a$2lk m9i$1@ID-198343.news.uni-berlin.de...[color=blue]
            > It's exactly what I do now, but unfortunately that key is not always[/color]
            present[color=blue]
            > in Windows 98
            >
            >
            > "Ken Tucker [MVP]" <vb2ae@bellsout h.net> ha scritto nel messaggio
            > news:eZx5Gt8GEH A.3472@TK2MSFTN GP11.phx.gbl...[color=green]
            > > Hi,
            > >
            > > It is in the registry
            > >
            > > Dim myReg As RegistryKey = Registry.LocalM achine
            > >
            > > Dim MyRegKey As RegistryKey
            > >
            > > Dim MyVal As String
            > >
            > > MyRegKey =
            > > myReg.OpenSubKe y("HARDWARE\DES CRIPTION\SYSTEM \CentralProcess or\0")
            > >
            > > MyVal = MyRegKey.GetVal ue("~Mhz")
            > >
            > > MyRegKey.Close( )
            > >
            > > txtRegistry.Tex t = String.Format(" CPU Speed {0}", MyVal)
            > >
            > >
            > >
            > > Ken
            > >
            > > --------------------
            > >
            > > "Claudio Di Flumeri" <claudioNOSPAM@ mtgc.net> wrote in message
            > > news:c4u16o$2lc 1sq$1@ID-198343.news.uni-berlin.de...[color=darkred]
            > > > Is there a way to get the CPU speed (in Mhz) without using WMI? I need[/color][/color]
            > to[color=green][color=darkred]
            > > > include this functionality in a program that have to work also in[/color][/color]
            > Windows[color=green]
            > > 98[color=darkred]
            > > > and I don't want to distributeWMI apart.
            > > >
            > > >[/color]
            > >
            > >
            > >[/color]
            >
            >
            >[/color]


            Comment

            • Brian Henry

              #7
              Re: CPU Speed

              you could calculate it, im not sure of the exact algoritm, but if you count
              how many loops you can do in a certain period of time you can determin the
              frequency of the clock in the system

              like in one second, how many for loops can you do at CPU process usaged 100%
              take that divide it out, figure out the number of processes that occured
              then something else and that equals your speed in MHz.. there is some
              documents on calculating MHz speeds on google if you search for it.


              "Claudio Di Flumeri" <claudioNOSPAM@ mtgc.net> wrote in message
              news:c4uj3a$2lk m9i$1@ID-198343.news.uni-berlin.de...[color=blue]
              > It's exactly what I do now, but unfortunately that key is not always[/color]
              present[color=blue]
              > in Windows 98
              >
              >
              > "Ken Tucker [MVP]" <vb2ae@bellsout h.net> ha scritto nel messaggio
              > news:eZx5Gt8GEH A.3472@TK2MSFTN GP11.phx.gbl...[color=green]
              > > Hi,
              > >
              > > It is in the registry
              > >
              > > Dim myReg As RegistryKey = Registry.LocalM achine
              > >
              > > Dim MyRegKey As RegistryKey
              > >
              > > Dim MyVal As String
              > >
              > > MyRegKey =
              > > myReg.OpenSubKe y("HARDWARE\DES CRIPTION\SYSTEM \CentralProcess or\0")
              > >
              > > MyVal = MyRegKey.GetVal ue("~Mhz")
              > >
              > > MyRegKey.Close( )
              > >
              > > txtRegistry.Tex t = String.Format(" CPU Speed {0}", MyVal)
              > >
              > >
              > >
              > > Ken
              > >
              > > --------------------
              > >
              > > "Claudio Di Flumeri" <claudioNOSPAM@ mtgc.net> wrote in message
              > > news:c4u16o$2lc 1sq$1@ID-198343.news.uni-berlin.de...[color=darkred]
              > > > Is there a way to get the CPU speed (in Mhz) without using WMI? I need[/color][/color]
              > to[color=green][color=darkred]
              > > > include this functionality in a program that have to work also in[/color][/color]
              > Windows[color=green]
              > > 98[color=darkred]
              > > > and I don't want to distributeWMI apart.
              > > >
              > > >[/color]
              > >
              > >
              > >[/color]
              >
              >
              >[/color]


              Comment

              • JackRazz

                #8
                Re: CPU Speed

                here is a small assembler snippit I used a few years ago. I don't know how to
                compile it in VS, but it should be possible to compile this in C++ as a dll and then
                call the dll from VB.NET.

                JackRazz



                ..586p
                ..Model Flat ,StdCall
                UNICODE=0
                Extrn _wsprintfA : near
                include w32.inc

                ..data

                capt db 'CPU Test',0
                format db 'CPU Speed = %lu Mhz',0
                buffer db 30 dup (0)

                ..code

                main:
                xor eax,eax
                rdtsc
                mov ebx,eax
                call Sleep, 1000
                rdtsc
                sub eax,ebx
                sub eax,8
                xor edx,edx
                mov ecx,1000000
                div ecx
                call _wsprintfA, offset buffer, offset format, eax
                call MessageBoxA, 0 ,offset buffer, offset capt, 0
                call ExitProcess , 0

                end main





                "Claudio Di Flumeri" <claudioNOSPAM@ mtgc.net> wrote in message
                news:c4u16o$2lc 1sq$1@ID-198343.news.uni-berlin.de...
                | Is there a way to get the CPU speed (in Mhz) without using WMI? I need to
                | include this functionality in a program that have to work also in Windows 98
                | and I don't want to distributeWMI apart.
                |
                |


                Comment

                • JackRazz

                  #9
                  Re: CPU Speed

                  here is a small assembler snippit I used a few years ago. I don't know how to
                  compile it in VS, but it should be possible to compile this in C++ as a dll and then
                  call the dll from VB.NET.

                  JackRazz



                  ..586p
                  ..Model Flat ,StdCall
                  UNICODE=0
                  Extrn _wsprintfA : near
                  include w32.inc

                  ..data

                  capt db 'CPU Test',0
                  format db 'CPU Speed = %lu Mhz',0
                  buffer db 30 dup (0)

                  ..code

                  main:
                  xor eax,eax
                  rdtsc
                  mov ebx,eax
                  call Sleep, 1000
                  rdtsc
                  sub eax,ebx
                  sub eax,8
                  xor edx,edx
                  mov ecx,1000000
                  div ecx
                  call _wsprintfA, offset buffer, offset format, eax
                  call MessageBoxA, 0 ,offset buffer, offset capt, 0
                  call ExitProcess , 0

                  end main





                  "Claudio Di Flumeri" <claudioNOSPAM@ mtgc.net> wrote in message
                  news:c4u16o$2lc 1sq$1@ID-198343.news.uni-berlin.de...
                  | Is there a way to get the CPU speed (in Mhz) without using WMI? I need to
                  | include this functionality in a program that have to work also in Windows 98
                  | and I don't want to distributeWMI apart.
                  |
                  |


                  Comment

                  Working...