Results 1 to 13 of 13

Thread: CPU

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 1999
    Location
    France
    Posts
    90

    Post

    Is it possible to find the CPU number of the computer using VB?

  2. #2
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923

    Post

    What do you want it for? If it's for copy protection, you could use the Hard disk serial number instead. see http://www.vb-world.net/tips/tip29.html

    kind regards,

    ------------------
    - Chris
    [email protected]
    If it ain't broke - don't fix it

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Feb 1999
    Location
    France
    Posts
    90

    Post

    I needed it because I'm making software that people can download from the internet - no CD-ROMs etc. The software will only work on the computer on which it has been downloaded.

    They will be asked to click a button which will show their CPU in a textbox. They will then email me this number, and we will give them another number - based on a formula involving the CPU they gave us. The first time they start the app, it will check against the CPU they gave us, to ensure that the formula matches. So the number is specific to their PC - if they copy the software and give it to others, it won't work on other peoples computers.

    So, does anyone know how I can get the CPU of a computer? Is it possible?

  4. #4
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923

    Post

    It is possible apparently, you can use the GetSystemInfo API, but that's all I can tell you.

    Regards,

    ------------------
    - Chris
    [email protected]
    If it ain't broke - don't fix it

  5. #5
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    Take a look at the Post I replied to earlier.

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

    Serge

    Software Developer
    [email protected]
    [email protected]
    ICQ#: 51055819


  6. #6

    Thread Starter
    Lively Member
    Join Date
    Feb 1999
    Location
    France
    Posts
    90

    Post

    Thanks a lot, Serge.

    However, it doesn't give me the CPU number - I know it should be something like 5512768, or something like that. Is there a small change to the code I should make? If you knew, it would be great.

    One other thing. In your program, when I ran it, it said 'CPU Level: Intel Pentium Pro or Pentium II'.

    I purchased a Pentium III 450Mgz (or at least I thought I did!). Should it say Pentium III instead of Pentium II, if it was a Pentium III? Should I get on to the retailer scumbag who I purchased it from? Thanks for any help!

  7. #7
    Guest

    Post

    Even though you have PIII, the reading should say PII. Why? I have no clue...ask Intel.

  8. #8
    Member
    Join Date
    May 1999
    Posts
    49

    Post

    It's not possible to get the CPU number using VB. I've seen this question so many times on so many boards. Maybe you could use C++ or Java? You could settle for the Windows Key number.

    Option Explicit
    Private Const HKEY_LOCAL_MACHINE = &H80000002
    Private Const ERROR_SUCCESS = 0&
    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
    Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
    Function GetRegistryString(hKey As Long, strPath As String, strValue As String, Optional Default As String, Optional Test As Boolean) As String
    Dim hCurKey As Long
    Dim lResult As Long
    Dim lValueType As Long
    Dim strBuffer As String
    Dim lDataBufferSize As Long
    Dim intZeroPos As Integer
    Dim lRegResult As Long
    ' Set up default value
    If Not IsEmpty(Default) Then
    GetRegistryString = Default
    Else
    GetRegistryString = ""
    End If
    lRegResult = RegOpenKey(hKey, strPath, hCurKey)
    lRegResult = RegQueryValueEx(hCurKey, strValue, 0&, lValueType, ByVal 0&, lDataBufferSize)
    If lRegResult = ERROR_SUCCESS Then
    If lValueType = REG_SZ Then
    strBuffer = String(lDataBufferSize, " ")
    lResult = RegQueryValueEx(hCurKey, strValue, 0&, 0&, ByVal strBuffer, lDataBufferSize)
    intZeroPos = InStr(strBuffer, Chr$(0))
    If intZeroPos > 0 Then
    GetRegistryString = Left$(strBuffer, intZeroPos - 1)
    Else
    GetRegistryString = strBuffer
    End If
    End If
    Else
    ' there is a problem
    End If lRegResult = RegCloseKey(hCurKey)
    End Function
    Private Sub Command1_Click()
    MsgBox GetWindowsProductKey
    End Sub
    Function GetWindowsProductKey() As String
    GetWindowsProductKey = GetRegistryString(HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion", "ProductKey")
    End Function

  9. #9
    Addicted Member
    Join Date
    May 1999
    Location
    Californ-I- A
    Posts
    207

    Post

    As far as I've heard, Pentium III cpu's etc show up a PII's but are in fact genuine PIII's. Benchmark it see what it shows, and if it isn't a 450, and you have it clocked as such, it'd probably weaken the stability of your entire system.

  10. #10
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    In WinNT you can get the approximate clock speed of the CPU. It is stored in the regigistry:

    HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0

    Then value of that Key is: ~MHz


    Also, Microsoft doesn't have a new GetSytemInfo API to check for PIII yet. Let's wait and found out.

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

    Serge

    Software Developer
    [email protected]
    [email protected]
    ICQ#: 51055819


  11. #11
    Lively Member
    Join Date
    Nov 1999
    Posts
    98

    Post

    richie -

    when i run the code for finding the product key i get an erroe at this line:

    If lValueType = REG_SZ Then

    it says REG_SZ variable not defined. why? i can't find it in the winapi.txt file so i don't know what the constant is or how to define it. could you help me out please? thank you very much.

    --michael

  12. #12
    Lively Member
    Join Date
    Nov 1999
    Posts
    98

    Post

    also...if you were very gung-ho about writing your program in VB, wouldn't there be a way to write a .dll in C/C++ and use it in VB declarations to get to the CPU number somehow? maybe i am just talking outta my ass, but just an idea.

    --michael

  13. #13
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923

    Post

    Good point funkhead. I'll put this topic to the top by posting and see if we get a response. I dunno - I don't think you're talking out your arse...that's how most DLLs are written (according to someone who may have been... )

    Regards,

    ------------------
    - Chris
    [email protected]
    If it ain't broke - don't fix it

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