Attribute VB_Name = "modCPU_Intel" Option Explicit '============================================================================================================= ' ' modCPU_Intel Module ' ------------------- ' ' Created By : Kevin Wilson ' http://www.TheVBZone.com ( The VB Zone ) ' http://www.TheVBZone.net ( The VB Zone .net ) ' ' Last Update : July 18, 2000 ' ' VB Versions : 5.0 / 6.0 ' ' Requires : VBCPUINF.DLL (Intel CPU Information DLL for VB by Ray Mercer) ' ' Description : This module is meant to give you easy access to core information about your Intel Central ' Processing Unit (CPU) including speed, Type, Model, etc. ' ' NOTE : This module is based on CPUInf32.bas by Ray Mercer. Go to this web page for more information: ' http://www.shrinkwrapvb.com/cpuinfo.htm ' ' NOTE : Original the "CPUINF32.DLL" from Intel was compiled with the CDecl calling convention for ' the functions in speed.h. Visual Basic only works with the StdCall calling convention. ' Therefore it was necessary to create a "VB-friendly" version of this DLL in order to call the ' speed benchmarking functions. Ray Mercer has renamed the new VB-friendly DLL to "VBCPUINF.DLL" ' in order to avoid compatibility problems with Intel's original DLL. ' '============================================================================================================= ' ' LEGAL: ' ' You are free to use this code as long as you keep the above heading information intact and unchanged. Credit ' given where credit is due. Also, it is not required, but it would be appreciated if you would mention ' somewhere in your compiled program that that your program makes use of code written and distributed by ' Kevin Wilson (www.TheVBZone.com). Feel free to link to this code via your web site or articles. ' ' You may NOT take this code and pass it off as your own. You may NOT distribute this code on your own server ' or web site. You may NOT take code created by Kevin Wilson (www.TheVBZone.com) and use it to create products, ' utilities, or applications that directly compete with products, utilities, and applications created by Kevin ' Wilson, TheVBZone.com, or Wilson Media. You may NOT take this code and sell it for profit without first ' obtaining the written consent of the author Kevin Wilson. ' ' These conditions are subject to change at the discretion of the owner Kevin Wilson at any time without ' warning or notice. Copyright© by Kevin Wilson. All rights reserved. ' '============================================================================================================= ' Types / Enumerations Public Type FREQ_INFO In_Cycles As Long ' Internal clock cycles during test Ex_Ticks As Long ' Microseconds elapsed during test Raw_Freq As Long ' Raw frequency of CPU in MHz Norm_Freq As Long ' Normalized frequency of CPU in MHz End Type ' Windows APIs Public Declare Sub CopyMemory Lib "KERNEL32" Alias "RtlMoveMemory" (ByRef lpvDest As Any, ByRef lpvSource As Any, ByVal cbCopy As Long) ' VBCPUINF.DLL APIs Public Declare Sub CPU_Speed Lib "VBCPUINF.DLL" Alias "vbcpuspeed" (ByVal Clocks As Long, ByRef FreqInfo As FREQ_INFO) Public Declare Function CPU_SpeedNorm Lib "VBCPUINF.DLL" Alias "cpunormspeed" (ByVal Clocks As Long) As Long Public Declare Function CPU_SpeedRaw Lib "VBCPUINF.DLL" Alias "cpurawspeed" (ByVal Clocks As Long) As Long Public Declare Function CPU_Count Lib "VBCPUINF.DLL" Alias "ProcessorCount" () As Long Public Declare Function CPU_DLLVersion Lib "VBCPUINF.DLL" Alias "getdllversion" () As Integer Public Declare Function CPU_Features Lib "VBCPUINF.DLL" Alias "wincpufeatures" () As Long Public Declare Function CPU_ID Lib "VBCPUINF.DLL" Alias "wincpuid" () As Long Public Declare Function CPU_IDEx Lib "VBCPUINF.DLL" Alias "wincpuidext" () As Integer Public Declare Function CPU_IDSupport Lib "VBCPUINF.DLL" Alias "wincpuidsupport" () As Integer Public Declare Function CPU_TimeStampCode Lib "VBCPUINF.DLL" Alias "winrdtsc" () As Currency '====================================================================================== ' CPUDescription ' -------------- ' ' Purpose: ' -------- ' Returns a string description of the user's CPU along with the numeric representation ' of the string description. ' ' Param Use ' ------------------------------------ ' ReturnNumber Optional. Returns the number representation of the CPU ' ReturnDescription Optional. Returns the string description of the CPU ' VerboseDescription Optional. If set to TRUE, the description will be longer ' ' Return: ' ------- ' FAIL - Returns False ' SUCCESS - Returns True ' '====================================================================================== Public Function CPUDescription(Optional ByRef ReturnNumber As Long, Optional ByRef ReturnDescription As String, Optional ByVal VerboseDescription As Boolean = False) As Boolean On Error Resume Next Dim CombinedValues As Long Dim lngType As Long Dim lngFamily As Long Dim lngModel As Long ' Reset the return values ReturnNumber = -1 ReturnDescription = "" ' Get the CPU Type, Family, & Model lngFamily = CPU_ID() CPUType lngType CPUModel lngModel ' Combine the values to get the right CPU lngType = lngType * 256 ' Shift left 8 bits lngFamily = lngFamily * 16 ' Shift left 4 bits CombinedValues = lngType Or lngFamily Or lngModel ' Combine all ten bits ' Return the number representation ReturnNumber = CombinedValues '---------------------------------------------------------------- '10bit CombinedValues Definitions 'Taken from Intel application note AP-485 (Intel Order #241618) '---------------------------------------------------------------- 'TYPE FAMILY MODEL Combined Description '---------------------------------------------------------------- '00 0100 0000 64 Intel 486 '00 0100 0001 65 Intel 486 '00 0100 0010 66 Intel 486SX '00 0100 0011 67 Intel 487, DX2, or OverDrive '00 0100 0100 68 Intel 486SL '00 0100 0101 69 Intel 486SX2 '00 0100 0111 71 Write-Back Enhanced Intel DX2 '00 0100 1000 72 Intel DX4 or DX4 OverDrive '01 0100 1000 328 Intel DX4 OverDrive '00 0101 0001 81 Pentium (60, 66) '00 0101 0010 82 Pentium (75, 90, 100, 120, 133, 150, 166, 200) '01 0101 0001 337 Pentium OverDrive (60, 66) '01 0101 0010 338 Pentium OverDrive (75, 90, 100, 120, 133) '01 0101 0011 339 Pentium OverDrive For 486 '00 0101 0100 84 Pentium with MMX (166, 200) '01 0101 0100 340 Pentium OverDrive with MMX (75, 90, 100, 120, 133) '00 0110 0001 97 Pentium Pro '00 0110 0011 99 Pentium II model 3 '00 0110 0101 101 Pentium II model 5 or Celeron ' 102 Celeron A '01 0110 0011 355 [ Reserved for future Pentium Pro OverDrive ] '---------------------------------------------------------------- If VerboseDescription = True Then Select Case CombinedValues Case 64, 65 ReturnDescription = "Intel 486 Processor" Case 66 ReturnDescription = "Intel 486SX Processor" Case 67 ReturnDescription = "Intel 487, DX2, or OverDrive Processor" Case 68 ReturnDescription = "Intel 486SL Processor" Case 69 ReturnDescription = "Intel 486SX2 Processor" Case 71 ReturnDescription = "Write-Back Enhanced Intel DX2 Processor" Case 72 ReturnDescription = "Intel DX4 or DX4 OverDrive Processor" Case 328 ReturnDescription = "Intel DX4 OverDrive Processor" Case 81 ReturnDescription = "Pentium Processor (60, 66)" Case 82 ReturnDescription = "Pentium Processor (75, 90, 100, 120, 133, 150, 166, 200)" Case 337 ReturnDescription = "Pentium OverDrive Processor (60, 66)" Case 338 ReturnDescription = "Pentium OverDrive Processor (75, 90, 100, 120, 133)" Case 339 ReturnDescription = "Pentium OverDrive Processor For 486-based Systems" Case 84 ReturnDescription = "Pentium Processor with MMX (166, 200)" Case 340 ReturnDescription = "Pentium OverDrive Processor with MMX (75, 90, 100, 120, 133)" Case 97 ReturnDescription = "Pentium Pro Processor" Case 99 ReturnDescription = "Pentium II Processor (model 3)" Case 101 ReturnDescription = "Pentium II (model 5) or Celeron Processor" Case 102 ReturnDescription = "Pentium II Celeron A Processor" Case 355 ReturnDescription = "Pentium Pro OverDrive Processor" Case Else ReturnDescription = "Unknown" End Select Else Select Case CombinedValues Case 64 - 69, 71 ReturnDescription = "486" Case 72, 328 ReturnDescription = "486DX4" Case 81, 82, 337 - 339 ReturnDescription = "Pentium" Case 84, 340 ReturnDescription = "PentiumMMX" Case 97, 355 ReturnDescription = "PentiumPro" Case 99 ReturnDescription = "PentiumII" Case 101 ReturnDescription = "PentiumII/Celeron" Case 102 ReturnDescription = "PentiumII/CeleronA" Case Else ReturnDescription = "Unknown" End Select End If CPUDescription = True End Function '====================================================================================== ' CPUTimeStamp ' ------------ ' ' Purpose: ' -------- ' Returns the major and minor version of the "VBCPUINF.DLL" file in the format of X.XX ' ' Param Use ' ------------------------------------ ' ReturnVersion Recieves a String representation of the DLL version number ' ' Return: ' ------- ' FAIL - Returns False ' SUCCESS - Returns True ' '====================================================================================== Public Function CPUDLLVersion(ByRef ReturnVersion As String) As Boolean On Error Resume Next Dim TheTempVer As Integer Dim VerMajor As Byte Dim VerMinor As Byte ' Reset the return values ReturnVersion = "" ' Get the version as an integer and break it into it's High Order / Low Order parts ' to get the Major / Minor revision numbers TheTempVer = CPU_DLLVersion() If TheTempVer = 0 Then CPUDLLVersion = False Else VerMajor = (TheTempVer And &HFF00) / &HFF VerMinor = (TheTempVer And &HFF) ReturnVersion = Format(VerMajor, "##0") & "." & Format(VerMinor, "##00") CPUDLLVersion = True End If End Function '====================================================================================== ' CPUHasFPU ' --------- ' ' Purpose: ' -------- ' Returns whether the CPU has a Floating Point Processor (FPU) built into it. ' ' Param Use ' ------------------------------------ ' ReturnFPU Recieves TRUE if the CPU has a built in FPU ' Recieves FALSE if it does not ' ' Return: ' ------- ' FAIL - Returns False ' SUCCESS - Returns True ' '====================================================================================== Public Function CPUHasFPU(ByRef ReturnFPU As Boolean) As Boolean On Error Resume Next Dim BitFlags As Long ' Reset the return values ReturnFPU = False ' Get the bit flags and check bit #0 to see if an FPU is present BitFlags = CPU_Features() If BitFlags = 0 Then CPUHasFPU = False ReturnFPU = False Else GetBit CPUHasFPU, BitFlags, 0 CPUHasFPU = True End If End Function '====================================================================================== ' CPUHasMMX ' --------- ' ' Purpose: ' -------- ' Returns whether the CPU has MultiMedia eXtensions (MMX) built into it or not. ' ' Param Use ' ------------------------------------ ' ReturnMMX Recieves TRUE if the CPU supports MMX ' Recieves FALSE if it does not ' ' Return: ' ------- ' FAIL - Returns False ' SUCCESS - Returns True ' '====================================================================================== Public Function CPUHasMMX(ByRef ReturnMMX As Boolean) As Boolean On Error Resume Next Dim BitFlags As Long ' Reset the return values ReturnMMX = False ' Get the bit flags and check bit #23 to see if MMX is supported BitFlags = CPU_Features() If BitFlags = 0 Then ReturnMMX = False CPUHasMMX = False Else GetBit ReturnMMX, BitFlags, 23 CPUHasMMX = True End If End Function '====================================================================================== ' CPUHasTSU ' --------- ' ' Purpose: ' -------- ' Returns whether the CPU has a Time Stamp Counter (TSU) built into it. ' ' Param Use ' ------------------------------------ ' ReturnTSU Recieves TRUE if the CPU supports TSU ' Recieves FALSE if it does not ' ' Return: ' ------- ' FAIL - Returns False ' SUCCESS - Returns True ' '====================================================================================== Public Function CPUHasTSU(ByRef ReturnTSU As Boolean) As Boolean On Error Resume Next Dim BitFlags As Long ' Reset the return values ReturnTSU = False ' Get the bit flags and check bit #4 to see if an TSU is supported BitFlags = CPU_Features() If BitFlags = 0 Then ReturnTSU = False CPUHasTSU = False Else GetBit ReturnTSU, BitFlags, 4 CPUHasTSU = True End If End Function '====================================================================================== ' CPUModel ' -------- ' ' Purpose: ' -------- ' Returns the CPU Model if the processor supports the CPUID opcode. Otherwise, ' returns zero. ' ' Param Use ' ------------------------------------ ' ReturnModel Recieves the model number ' ' Return: ' ------- ' FAIL - Returns False ' SUCCESS - Returns True ' '====================================================================================== Public Function CPUModel(ByRef ReturnModel As Long) As Boolean On Error Resume Next Dim BitFlags As Integer Dim LowByte As Byte ' Reset the return values ReturnModel = -1 ' Get the CPU model information to be parced BitFlags = CPU_IDEx() ' Get LowByte of the 32bit return value while masking Lowest Nibble LowByte = BitFlags And &HF0& ' Shift High Nibble to LowNibble If LowByte = 0 Then CPUModel = False Else ReturnModel = LowByte / 16 CPUModel = True End If End Function '====================================================================================== ' CPUSpeed ' -------- ' ' Purpose: ' -------- ' Returns the normalized speed of the CPU ' ' Param Use ' ------------------------------------ ' ReturnSpeed Recieves a String representation of the CPU speed in MHz ' ' Return: ' ------- ' FAIL - Returns False ' SUCCESS - Returns True ' '====================================================================================== Public Function CPUSpeed(ByRef ReturnSpeed As String) As Boolean On Error Resume Next Dim TheSpeed As Long ' Reset the return values ReturnSpeed = "" ' Get the CPU speed and format it TheSpeed = CPU_SpeedNorm(0&) If TheSpeed = 0 Then CPUSpeed = False Else ReturnSpeed = CStr(TheSpeed) & " MHz" CPUSpeed = True End If End Function '====================================================================================== ' CPUTimeStamp ' ------------ ' ' Purpose: ' -------- ' Returns the value in the Time Stamp Counter (if one exists). ' ' NOTE: ' ----- ' Since VB can't handle 64bit integer values natively we must use a Currency type ' and the CopyMemory() API to get the Low Order and High Order of the return value. ' (Can you say "hack"?) ' ' Param Use ' ------------------------------------ ' TimeStamp_STR Optional. Recieves a String representation of the time stamp ' TimeStamp_HI Optional. Recieves a Long representation of the time stamp High Order ' TimeStamp_LO Optional. Recieves a Long representation of the time stamp Low Order ' ' Return: ' ------- ' FAIL - Returns False ' SUCCESS - Returns True ' '====================================================================================== Public Function CPUTimeStamp(Optional ByRef TimeStamp_STR As String, Optional ByRef TimeStamp_HI As Long, Optional ByRef TimeStamp_LO As Long) As Boolean On Error Resume Next Dim TheTS As Currency Dim HighOrder As Long Dim LowOrder As Long ' Reset the return values TimeStamp_STR = "" TimeStamp_HI = -1 TimeStamp_LO = -1 ' Retrieve 64bit time stamp value TheTS = CPU_TimeStampCode() ' Check if the CPU has a register to get the information from If TheTS = 0 Then MsgBox "CPU does not have a time stamp register.", vbOKOnly + vbExclamation, " Register Found" TimeStamp_STR = "" TimeStamp_HI = 0 TimeStamp_LO = 0 CPUTimeStamp = False Exit Function End If ' Get the two 32bit values from the 64bit value CopyMemory HighOrder, TheTS, 4 CopyMemory LowOrder, ByVal VarPtr(TheTS) + 4, 4 ' Return the time stamp as a readable string value TimeStamp_STR = Hex(HighOrder) TimeStamp_STR = TimeStamp_STR & " : " & Hex(LowOrder) TimeStamp_HI = HighOrder TimeStamp_LO = LowOrder CPUTimeStamp = True End Function '====================================================================================== ' CPUType ' ------- ' ' Purpose: ' -------- ' Returns the CPU Model if the processor supports the CPUID opcode. Otherwise, ' returns zero. ' ' Param Use ' ------------------------------------ ' ReturnType Recieves the CPU type number ' 0 = Standard OEM CPU ' 1 = OverDrive ' 2 = Dual CPU ' 3 = Unknown (Reserved) ' ' Return: ' ------- ' FAIL - Returns False ' SUCCESS - Returns True ' '====================================================================================== Public Function CPUType(ByRef ReturnType As Long) As Boolean On Error Resume Next Dim BitFlags As Integer Dim Bit1 As Boolean Dim Bit2 As Boolean ' Reset the return values ReturnType = -1 ' Get the flags and check the bits BitFlags = CPU_IDEx() GetBit Bit1, BitFlags, 13 GetBit Bit2, BitFlags, 12 If Bit1 = True Then If Bit2 = True Then ' 11 - Reserved ReturnType = 3 Else ' 10 - Dual CPU ReturnType = 2 End If Else If Bit2 = True Then ' 01 - OverDrive ReturnType = 1 Else ' 00 - Standard OEM CPU ReturnType = 0 End If End If End Function '====================================================================================== ' GetBit ' ------ ' ' Purpose: ' -------- ' Return the value ( 1 or 0 ) of the specified Bit in a 32 bit value ' ' NOTE: ' ----- ' Based on a similar function in "Hardcore VB5" by Bruce McKinney by Ray Mercer ' ' Param Use ' ------------------------------------ ' ReturnValue Returns TRUE if the bit flag is set, or FALSE if it is not ' TheValue The 32 bit number to check ' TheBitPosition The bit position to check ' ' Return: ' ------- ' FAIL - Returns False ' SUCCESS - Returns True ' '====================================================================================== Private Function GetBit(ByRef ReturnValue As Boolean, ByVal TheValue As Long, ByVal TheBitPosition As Integer) As Boolean On Error Resume Next Dim BitVal As Long ' Make sure the bit position is valid If TheBitPosition < 0 Or TheBitPosition > 31 Then ReturnValue = False Exit Function End If ' Reset the value to FALSE ReturnValue = False ' Test the bit value Select Case TheBitPosition Case 0 BitVal = &H1& Case 1 BitVal = &H2& Case 2 BitVal = &H4& Case 3 BitVal = &H8& Case 4 BitVal = &H10& Case 5 BitVal = &H20& Case 6 BitVal = &H40& Case 7 BitVal = &H80& Case 8 BitVal = &H100& Case 9 BitVal = &H200& Case 10 BitVal = &H400& Case 11 BitVal = &H800& Case 12 BitVal = &H1000& Case 13 BitVal = &H2000& Case 14 BitVal = &H4000& Case 15 BitVal = &H8000& Case 16 BitVal = &H10000 Case 17 BitVal = &H20000 Case 18 BitVal = &H40000 Case 19 BitVal = &H80000 Case 20 BitVal = &H100000 Case (21) BitVal = &H200000 Case (22) BitVal = &H400000 Case (23) BitVal = &H800000 Case (24) BitVal = &H1000000 Case (25) BitVal = &H2000000 Case (26) BitVal = &H4000000 Case (27) BitVal = &H8000000 Case (28) BitVal = &H10000000 Case (29) BitVal = &H20000000 Case (30) BitVal = &H40000000 Case (31) BitVal = &H80000000 End Select ReturnValue = TheValue And BitVal GetBit = True End Function 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX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XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX '====================================================================================== ' API DOCUMENTATION '====================================================================================== '====================================================================================== ' CPU_Speed ' -------- ' ' Purpose: ' -------- ' Return the raw clock rate of the host CPU. ' ' Param Use ' ------------------------------------ ' Clocks Number of cycles per BSF (Default = 10) ' * NULL : Use default value for number of cycles per ' BSF instruction ' * Positive Integer : Use clocks value for number of ' cycles per BSF instruction. ' * -1 : Use CMos timer to calculate speed ' (May not work for WinNT) ' FreqInfo: Recieves the information - fills the FREQ_INFO struct ' (UDT) passed to it ' ' Return: ' ------- ' FAIL - Returns all zeroes in FREQ_INFO structure ' SUCCESS - Returns FREQ_INFO structure containing calculated clock ' frequency, normalized clock frequency, number of clock cycles ' during test sampling, and the number of microseconds elapsed ' during the sampling. ' '====================================================================================== 'Public Declare Sub CPU_Speed Lib "VBCPUINF.DLL" Alias "vbcpuspeed" (ByVal Clocks As Long, ByRef FreqInfo As FREQ_INFO) '====================================================================================== ' CPU_SpeedNorm ' ----------- ' ' Purpose: ' -------- ' Returns only FREQ_INFO.norm_freq member ' ' Param Use ' ------------------------------------ ' Clocks Number of cycles per BSF (Default = 10) ' * NULL : Use default value for number of cycles per ' BSF instruction - note* default value is 10 ' * Positive Integer : Use clocks value for number of ' cycles per BSF instruction. ' * -1 : Use CMos timer to calculate speed ' (May not work for WinNT) ' ' Return: ' ------- ' FAIL - Returns 0 ' SUCCESS - Returns FREQ_INFO.norm_freq member ' '====================================================================================== 'Public Declare Function CPU_SpeedNorm Lib "VBCPUINF.DLL" Alias "cpunormspeed" (ByVal Clocks As Long) As Long '====================================================================================== ' CPU_SpeedRaw ' ----------- ' ' Purpose: ' -------- ' Returns only FREQ_INFO.raw_freq member ' ' Param Use ' ------------------------------------ ' Clocks Number of cycles per BSF (Default = 10) ' * NULL : Use default value for number of cycles per ' BSF instruction - note* default value is 10 ' * Positive Integer : Use clocks value for number of ' cycles per BSF instruction. ' * -1 : Use CMos timer to calculate speed ' (May not work for WinNT) ' ' Return: ' ------- ' FAIL - Returns 0 ' SUCCESS - Returns FREQ_INFO.raw_freq member ' '====================================================================================== 'Public Declare Function CPU_SpeedRaw Lib "VBCPUINF.DLL" Alias "cpurawspeed" (ByVal Clocks As Long) As Long '====================================================================================== ' CPU_Count ' -------- ' ' Purpose: ' -------- ' Returns how many CPUs are present on the user's computer ' ' Param Use ' ------------------------------------ ' (None) ' ' Return: ' ------- ' FAIL - Returns 0 ' SUCCESS - Returns number of CPUs ' '====================================================================================== 'Public Declare Function CPU_Count Lib "VBCPUINF.DLL" Alias "ProcessorCount" () As Long '====================================================================================== ' CPU_DLLVersion ' -------------- ' ' Purpose: ' -------- ' Returns the version number of the VBCPUINF.DLL in the form of a 16 bit ' number, which can be broken down into it's High Order & Low Order values ' to get the Major and Minor revision numbers like this: ' ' ----------- ' ' Dim TheTempVer As Integer ' Dim VerMajor As Byte ' Dim VerMinor As Byte ' Dim TheVer As String ' ' TheTempVer = CPU_DLLVersion() ' VerMajor = (TheTempVer And &HFF00) / &HFF ' VerMinor = (TheTempVer And &HFF) ' TheVer = Format(VerMajor, "##0") & "." & Format(VerMinor, "##00") ' ' ----------- ' ' Param Use ' ------------------------------------ ' (None) ' ' Return: ' ------- ' FAIL - Returns 0 ' SUCCESS - Returns a 16bit number that is made up of 2x8 numbers that ' make up the .DLL's version number ' '====================================================================================== 'Public Declare Function CPU_DLLVersion Lib "VBCPUINF.DLL" Alias "getdllversion" () As Integer '====================================================================================== ' CPU_Features ' ------------ ' ' Purpose: ' -------- ' Returns a 32 bit number where each bit is a TRUE/FALSE (1/0) flag for a ' certain feature as described below. Use the "GetBit" to get the bit ' value for the flag you need to check. The bit flags are defined as ' follows : ' ' Bit 0 = CPU contains a floating-point unit (FPU) ' Bit 1 = Enhanced virtual 8086 mode support ' Bit 2 = I/O breakpoints supported ' Bit 3 = Page size extensions supported ' Bit 4 = Time Stamp Counter (TSC) supported ' Bit 5 = iPentium style MSRs supported ' Bit 6 = Physical address extension supported ' Bit 7 = Machine check exception supported ' Bit 8 = CMPXCHG8B instruction supported ' Bit 9 = CPU contains a local APIC (iPentium-3V) ' Bit 10 = [ Reserved ] ' Bit 11 = Fast system call (SYSENTER, SYSEXIT) supported ' Bit 12 = Memory type range registers (MTRR_CAP) supported ' Bit 13 = Page global enable support ' Bit 14 = Machine check architecture (MCG_CAP) supported ' Bit 15 = Conditional move instruction supported ' Bit 16 = Page attribute table supported ' Bit 17 = 36 bit page size extension supported ' Bit 18 = [ Reserved ] ' Bit 19 = [ Reserved ] ' Bit 20 = [ Reserved ] ' Bit 21 = [ Reserved ] ' Bit 22 = [ Reserved ] ' Bit 23 = MMX Supported ' Bit 24 = Fast floating point save and restore support ' Bit 25 = [ Reserved ] ' Bit 26 = [ Reserved ] ' Bit 27 = [ Reserved ] ' Bit 28 = [ Reserved ] ' Bit 29 = [ Reserved ] ' Bit 30 = [ Reserved ] ' Bit 31 = [ Reserved ] ' ' NOTE : New bits will be assigned on future processors. ' (see processor data books for updated information) ' ' Param Use ' ------------------------------------ ' (None) ' ' Return: ' ------- ' FAIL - Returns 0 ' SUCCESS - Returns a 32bit number that is made up of 32 flags for the ' different features (0 to 31). ' '====================================================================================== 'Public Declare Function CPU_Features Lib "VBCPUINF.DLL" Alias "wincpufeatures" () As Long '====================================================================================== ' CPU_ID ' -------- ' ' Purpose: ' -------- ' This routine uses the standard Intel assembly code to determine what ' type of processor is in the computer, as described in application note ' AP-485 (Intel Order #241618). CPU_ID() returns the CPU type as an ' integer (that is, 2 bytes, a WORD) in the AX register. ' ' Param Use ' ------------------------------------ ' (None) ' ' Return: ' ------- ' 0 = 8086/88 ' 2 = 80286 ' 3 = 80386 ' 4 = 80486 ' 5 = Pentium(R) Processor ' 6 = PentiumPro(R) Processor ' 7 or higher = Processor beyond the PentiumPro6(R) Processor ' '====================================================================================== 'Public Declare Function CPU_ID Lib "VBCPUINF.DLL" Alias "wincpuid" () As Long '====================================================================================== ' CPU_IDEx ' -------- ' ' Purpose: ' -------- ' Returns the CPU model number ' ' Param Use ' ------------------------------------ ' (None) ' ' Return: ' ------- ' FAIL - Returns 0 ' SUCCESS - Returns CPU model number as 16 bit number. Bit 0 to 7 contain ' the CPU model information. ' '====================================================================================== 'Public Declare Function CPU_IDEx Lib "VBCPUINF.DLL" Alias "wincpuidext" () As Integer '====================================================================================== ' CPU_IDSupport ' --------------- ' ' Purpose: ' -------- ' Returns whether the user's processor supports the CPUID opcode or not. ' ' Param Use ' ------------------------------------ ' (None) ' ' Return: ' ------- ' 1 = CPUID opcode is supported ' 0 = CPUID opcode is NOT supported ' '====================================================================================== 'Public Declare Function CPU_IDSupport Lib "VBCPUINF.DLL" Alias "wincpuidsupport" () As Integer '====================================================================================== ' CPU_TimeStampCode ' ----------------- ' ' Purpose: ' -------- ' Returns the number of clock cycles since the CPU was powered up or reset. ' The time stampe code is returned as a 64 bit number that is split into ' a high-order and low-order value as follows: ' ' ----------- ' ' Dim TheTS As Currency ' Dim HighOrder As Long ' Dim LowOrder As Long ' ' TheTS = CPU_TimeStampCode() ' Retrieve 64bit time stamp value ' If TheTS <> 0 Then ' If return value is valid, get the values ' CopyMemory HighOrder, TheTS, 4 ' CopyMemory LowOrder, ByVal VarPtr(TheTS) + 4, 4 ' End If ' ' ----------- ' ' Param Use ' ------------------------------------ ' (None) ' ' Return: ' ------- ' FAIL - Returns 0 ' SUCCESS - Returns a 64bit number that is made up of 2x32 numbers that ' make up the time stamp value ' '====================================================================================== 'Public Declare Function CPU_TimeStampCode Lib "VBCPUINF.DLL" Alias "winrdtsc" () As Currency