|
Thread: CPU
-
Nov 29th, 1999, 07:24 AM
#1
Thread Starter
Lively Member
Is it possible to find the CPU number of the computer using VB?
-
Nov 29th, 1999, 11:35 AM
#2
PowerPoster
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 
-
Nov 29th, 1999, 05:35 PM
#3
Thread Starter
Lively Member
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?
-
Nov 29th, 1999, 05:39 PM
#4
PowerPoster
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 
-
Nov 29th, 1999, 07:58 PM
#5
Take a look at the Post I replied to earlier.
------------------
Serge
Software Developer
[email protected]
[email protected]
ICQ#: 51055819
-
Nov 30th, 1999, 05:16 AM
#6
Thread Starter
Lively Member
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!
-
Nov 30th, 1999, 05:38 AM
#7
Even though you have PIII, the reading should say PII. Why? I have no clue...ask Intel.
-
Nov 30th, 1999, 03:10 PM
#8
Member
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
-
Nov 30th, 1999, 03:48 PM
#9
Addicted Member
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.
-
Nov 30th, 1999, 08:17 PM
#10
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
-
Nov 30th, 1999, 09:01 PM
#11
Lively Member
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
-
Nov 30th, 1999, 09:03 PM
#12
Lively Member
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
-
Dec 1st, 1999, 09:26 AM
#13
PowerPoster
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|