Results 1 to 5 of 5

Thread: Reg_dword

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2005
    Posts
    294

    Reg_dword

    VB Code:
    1. Public Function ComputerProcessor() As String
    2.     On Error GoTo ErrorHandler
    3.     Dim hKey As Long
    4.     Dim Processor As String
    5.     Dim MHz As Long
    6.     ComputerProcessor = ""
    7.     If RegOpenKeyEx(HKEY_LOCAL_MACHINE, "HARDWARE\DESCRIPTION\System\CentralProcessor\0", 0, KEY_ALL_ACCESS, hKey) <> ERROR_SUCCESS Then
    8.         Form2.DebugPrint "ComputerProcessor.RegOpenKeyEx failed" & Err.Number
    9.         GoTo hClose
    10.     End If
    11.     Processor = Space$(128)
    12.     If RegQueryValueEx(hKey, "ProcessorNameString", 0&, REG_SZ, Processor, Len(Processor)) <> ERROR_SUCCESS Then
    13.         Form2.DebugPrint "ComputerProcessor.RegQueryValueEx(ProcessorNameString) failed" & Err.Number
    14.         GoTo hClose
    15.     End If
    16.     Processor = Left$(Processor, InStr(Processor, Chr(0)) - 1)
    17.     If RegQueryValueEx(hKey, "~MHz", 0&, REG_DWORD, MHz, 4&) <> ERROR_SUCCESS Then
    18.         Form2.DebugPrint "ComputerProcessor.RegQueryValueEx(MHz) failed" & Err.Number
    19.         GoTo hClose
    20.     End If
    21.     ComputerProcessor = Processor & " (" & MHz & "MHz)"
    22. hClose:
    23.     RegCloseKey hKey
    24.     Exit Function
    25. ErrorHandler:
    26.     Form2.DebugPrint "ComputerProcessor.Error: " & Err.Number
    27. End Function

    Returns "AMD Athlon(tm) XP 3000+ (0MHz)", whats wrong?

  2. #2
    eltiT resU motsuC Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Reg_dword

    u are trying to load a Hex number into a long.
    U need to conver from hex to long (or string)
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  3. #3
    eltiT resU motsuC Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Reg_dword

    oops forgot to say how:

    Dim strVar as String
    Now use strVar in your call to get the MHz...
    then
    Val("&H" & strVar)
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2005
    Posts
    294

    Re: Reg_dword

    It dont work.
    VB Code:
    1. Dim MHz As String
    2. MHz = Space$(128)
    3. RegQueryValueEx(hKey, "~MHz", 0&, REG_DWORD, MHz, Len(MHz))
    4. MHz = Left$(MHz, InStr(MHz, Chr(0)) - 1)
    5. MsgBox Val("&H" & MHz) & "MHz"

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2005
    Posts
    294

    Re: Reg_dword

    Bump

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