Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How do I retrieve CPU vendor info?
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
00985386
Message ID:
01087180
Views:
20
You can try the code below. I think it has been posted on the UT before:
? getprocessor()

FUNCTION getprocessor
m.value = ""
m.value = passtwo()+CHR(13)

HKEY_LOCAL_MACHINE = -2147483646
REG_SZ =   1
REG_BINARY = 3
REG_DWORD =   4
ERROR_SUCCESS = 0

PRIVATE nKey, cSubKey, cValue, cValueRead, m.value, value1, value2, value3, value4, value5, value6
m.value = m.value+"CPU Type: "+sys(17)+chr(13)
nkey = HKEY_LOCAL_MACHINE

cSubKey = "Hardware\DESCRIPTION\System\CentralProcessor\0"
cValue = "ProcessorNameString"
cValueRead=''
cValueRead = readreg_sz(nKey, cSubKey, cValue)
IF !EMPTY(cValueRead)
   m.value = m.value + "Processor 1: "+LTRIM(cValueRead)+CHR(13)
ENDIF

cSubKey = "Hardware\DESCRIPTION\System\CentralProcessor\1"
cValue = "ProcessorNameString"
cValueRead=''
cValueRead = readreg_sz(nKey, cSubKey, cValue)
IF !EMPTY(cValueRead)
   m.value = m.value + "Processor 2: "+LTRIM(cValueRead)+CHR(13)
ENDIF

cSubKey = "Hardware\DESCRIPTION\System\CentralProcessor\2"
cValue = "ProcessorNameString"
cValueRead=''
cValueRead = readreg_sz(nKey, cSubKey, cValue)
IF !EMPTY(cValueRead)
   m.value = m.value + "Processor 3: "+LTRIM(cValueRead)+CHR(13)
ENDIF

cSubKey = "Hardware\DESCRIPTION\System\CentralProcessor\3"
cValue = "ProcessorNameString"
cValueRead=''
cValueRead = readreg_sz(nKey, cSubKey, cValue)
IF !EMPTY(cValueRead)
   m.value = m.value + "Processor 4: "+LTRIM(cValueRead)+CHR(13)
ENDIF
RETURN m.value



PROCEDURE Readreg_sz
  LPARAMETERS  nKey, cSubKey, cValue
   
   IF TYPE('nkey')="L"
      RETURN ''
   ENDIF
   IF TYPE('cSubkey')="L"
      RETURN ""
   ENDIF
   IF TYPE('cValue') = "L"
      RETURN ""
   ENDIF
   
   #DEFINE REG_SZ   1

   DECLARE Integer RegOpenKey IN Win32API ;
      Integer nHKey, String @cSubKey, Integer @nResult
   DECLARE Integer RegQueryValueEx IN Win32API ;
      Integer nHKey, String lpszValueName, Integer dwReserved,;
      Integer @lpdwType, String @lpbData, Integer @lpcbData
   DECLARE Integer RegCloseKey IN Win32API Integer nHKey

   LOCAL nErrCode 
   LOCAL nKeyHandle
   LOCAL lpdwValueType
   LOCAL lpbValue     
   LOCAL lpcbValueSize
   LOCAL lpdwReserved 
    
   nKeyHandle = 0
   lpdwReserved = 0           
   lpdwValueType = REG_SZ
   lpbValue = ""
   
   nErrCode = RegOpenKey(nKey, cSubKey, @nKeyHandle)
   IF (nErrCode # 0) THEN
      RETURN ""
   ENDIF

   lpcbValueSize = 1 
   nErrCode=RegQueryValueEx(nKeyHandle, cValue, lpdwReserved, @lpdwValueType, @lpbValue, @lpcbValueSize)

   lpbValue = SPACE(lpcbValueSize)   
   nErrCode=RegQueryValueEx(nKeyHandle, cValue, lpdwReserved, @lpdwValueType, @lpbValue, @lpcbValueSize)
   
   =RegCloseKey(nKeyHandle)
   IF (nErrCode # 0) THEN
      RETURN ""
   ENDIF

   lpbValue = LEFT(lpbValue, lpcbValueSize - 1)
RETURN lpbValue

FUNCTION passtwo
newvalue = ''
VALUE1 = "Number of CPUs: " +GETENV("NUMBER_OF_PROCESSORS")+CHR(13)
value2 =  "Processor Architecture: " +GETENV("PROCESSOR_ARCHITECTURE")+CHR(13)
value3 =  "Processor Identifier: " +GETENV("PROCESSOR_IDENTIFIER")+CHR(13)
value4 =  "Processor Level: " +GETENV("PROCESSOR_LEVEL")+CHR(13)
value5 = "Processor Revision: " +GETENV("PROCESSOR_REVISION")+CHR(13)
newvalue = value1+value2+value3+value4+value5
RETURN newvalue
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Previous
Reply
Map
View

Click here to load this message in the networking platform