Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Obtain hardware serial numbers through vb 5 api or function?? 1

Status
Not open for further replies.

Roby

Programmer
Dec 20, 1999
3
MX
Hi, I know that my question is probably too technical, but I need an api or function to obtain a hardware( motherboard, processor) unique serial number.<br>
I really appreciate your help people!
 
'Flags for GetSystemInfo<br>
Private Const PROCESSOR_INTEL_386 As Long = 386<br>
Private Const PROCESSOR_INTEL_486 As Long = 486<br>
Private Const PROCESSOR_INTEL_PENTIUM As Long = 586<br>
Private Const PROCESSOR_MIPS_R4000 As Long = 4000<br>
Private Const PROCESSOR_ALPHA_21064 As Long = 21064<br>
Private Const PROCESSOR_PPC_601 As Long = 601<br>
Private Const PROCESSOR_PPC_603 As Long = 603<br>
Private Const PROCESSOR_PPC_604 As Long = 604<br>
Private Const PROCESSOR_PPC_620 As Long = 620<br>
Private Const PROCESSOR_HITACHI_SH3 As Long = 10003 'Windows CE<br>
Private Const PROCESSOR_HITACHI_SH3E As Long = 10004 'Windows CE<br>
Private Const PROCESSOR_HITACHI_SH4 As Long = 10005 'Windows CE<br>
Private Const PROCESSOR_MOTOROLA_821 As Long = 821 'Windows CE<br>
Private Const PROCESSOR_SHx_SH3 As Long = 103 'Windows CE<br>
Private Const PROCESSOR_SHx_SH4 As Long = 104 'Windows CE<br>
Private Const PROCESSOR_STRONGARM As Long = 2577 'Windows CE - 0xA11<br>
Private Const PROCESSOR_ARM720 As Long = 1824 'Windows CE - 0x720<br>
Private Const PROCESSOR_ARM820 As Long = 2080 'Windows CE - 0x820<br>
Private Const PROCESSOR_ARM920 As Long = 2336 'Windows CE - 0x920<br>
Private Const PROCESSOR_ARM_7TDMI As Long = 70001 'Windows CE<br>
<br>
Private Const PROCESSOR_ARCHITECTURE_INTEL As Long = 0<br>
Private Const PROCESSOR_ARCHITECTURE_MIPS As Long = 1<br>
Private Const PROCESSOR_ARCHITECTURE_ALPHA As Long = 2<br>
Private Const PROCESSOR_ARCHITECTURE_PPC As Long = 3<br>
Private Const PROCESSOR_ARCHITECTURE_SHX As Long = 4<br>
Private Const PROCESSOR_ARCHITECTURE_ARM As Long = 5<br>
Private Const PROCESSOR_ARCHITECTURE_IA64 As Long = 6<br>
Private Const PROCESSOR_ARCHITECTURE_ALPHA64 As Long = 7<br>
Private Const PROCESSOR_ARCHITECTURE_UNKNOWN As Long = &HFFFF<br>
<br>
Private Const PROCESSOR_LEVEL_80386 As Long = 3<br>
Private Const PROCESSOR_LEVEL_80486 As Long = 4<br>
Private Const PROCESSOR_LEVEL_PENTIUM As Long = 5<br>
Private Const PROCESSOR_LEVEL_PENTIUMII As Long = 6<br>
<br>
Private Const sCPURegKey = &quot;HARDWARE\DESCRIPTION\System\CentralProcessor\0&quot;<br>
<br>
Private Const HKEY_LOCAL_MACHINE As Long = &H80000002<br>
<br>
Private Type SYSTEM_INFO<br>
dwOemID As Long<br>
dwPageSize As Long<br>
lpMinimumApplicationAddress As Long<br>
lpMaximumApplicationAddress As Long<br>
dwActiveProcessorMask As Long<br>
dwNumberOfProcessors As Long<br>
dwProcessorType As Long<br>
dwAllocationGranularity As Long<br>
wProcessorLevel As Integer<br>
wProcessorRevision As Integer<br>
End Type<br>
<br>
Private Declare Sub GetSystemInfo Lib &quot;kernel32&quot; _<br>
(lpSystemInfo As SYSTEM_INFO)<br>
<br>
Private Declare Function RegCloseKey Lib &quot;advapi32.dll&quot; _<br>
(ByVal hKey As Long) As Long<br>
<br>
Private Declare Function RegOpenKey Lib &quot;advapi32.dll&quot; _<br>
Alias &quot;RegOpenKeyA&quot; _<br>
(ByVal hKey As Long, _<br>
ByVal lpSubKey As String, _<br>
phkResult As Long) As Long<br>
<br>
Private Declare Function RegQueryValueEx Lib &quot;advapi32.dll&quot; _<br>
Alias &quot;RegQueryValueExA&quot; _<br>
(ByVal hKey As Long, _<br>
ByVal lpValueName As String, _<br>
ByVal lpReserved As Long, _<br>
lpType As Long, _<br>
lpData As Any, _<br>
lpcbData As Long) As Long<br>
<br>
<br>
Private Sub Command1_Click()<br>
<br>
Dim SI As SYSTEM_INFO<br>
Dim tmp As String<br>
<br>
Call GetSystemInfo(SI)<br>
<br>
Print &quot;Number Of Processors&quot;, SI.dwNumberOfProcessors<br>
<br>
Select Case SI.dwProcessorType<br>
Case PROCESSOR_INTEL_386: tmp = &quot;386&quot;<br>
Case PROCESSOR_INTEL_486: tmp = &quot;486&quot;<br>
Case PROCESSOR_INTEL_PENTIUM: tmp = &quot;Pentium&quot;<br>
Case PROCESSOR_MIPS_R4000: tmp = &quot;MIPS 4000&quot;<br>
Case PROCESSOR_ALPHA_21064: tmp = &quot;Alpha&quot;<br>
End Select<br>
<br>
Print &quot;Processor Type&quot;, SI.dwProcessorType, tmp<br>
<br>
Select Case SI.wProcessorLevel<br>
Case PROCESSOR_LEVEL_80386: tmp = &quot;Intel 80386&quot;<br>
Case PROCESSOR_LEVEL_80486: tmp = &quot;Intel 80486&quot;<br>
Case PROCESSOR_LEVEL_PENTIUM: tmp = &quot;Intel Pentium&quot;<br>
Case PROCESSOR_LEVEL_PENTIUMII: tmp = &quot;Intel Pentium Pro or Pentium II&quot;<br>
End Select<br>
<br>
Print &quot;Processor Level&quot;, SI.wProcessorLevel, tmp<br>
<br>
Print &quot;Processor Revision&quot;, SI.wProcessorRevision, _<br>
&quot;Model &quot;; HiByte(SI.wProcessorRevision) & _<br>
&quot;, Stepping &quot; & LoByte(SI.wProcessorRevision)<br>
<br>
Print &quot;CPU Speed&quot;, , &quot; &quot; & GetCPUSpeed() & &quot; MHz&quot;<br>
<br>
End Sub<br>
<br>
<br>
Private Function GetCPUSpeed() As Long<br>
<br>
Dim hKey As Long<br>
Dim cpuSpeed As Long<br>
<br>
'Open CPU key<br>
Call RegOpenKey(HKEY_LOCAL_MACHINE, sCPURegKey, hKey)<br>
<br>
'and retrieve the value<br>
Call RegQueryValueEx(hKey, &quot;~MHz&quot;, 0, 0, cpuSpeed, 4)<br>
Call RegCloseKey(hKey)<br>
<br>
GetCPUSpeed = cpuSpeed<br>
<br>
End Function<br>
<br>
<br>
Public Function HiByte(ByVal wParam As Integer) As Byte<br>
<br>
'note: VB4-32 users should declare this function As Integer<br>
HiByte = (wParam And &HFF00&) \ (&H100)<br>
<br>
End Function<br>
<br>
<br>
Public Function LoByte(ByVal wParam As Integer) As Byte<br>
<br>
'note: VB4-32 users should declare this function As Integer<br>
LoByte = wParam And &HFF& <br>
<br>
End Function<br>
<br>
<br>
Eric De Decker
 
I have a question that I think is related to the above
basically I am looking for VB APIs that either tell me when a Print job is finisjhed or can generate a Postscript file(Print to file manually)
I am trying to automate the process
any help is appreciated
thanks
anu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top