Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Execscript problem
Message
From
04/01/2005 13:45:42
 
 
To
04/01/2005 13:35:22
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
00974147
Message ID:
00974153
Views:
20
This works:

=EXECSCRIPT(FILETOSTR("c1.prg"))
*c1.prg
m.value = ""
m.value = passtwo()+CHR(13)

HKEY_LOCAL_MACHINE = -2147483646
REG_SZ =	1	&& String
REG_BINARY = 3	&& Binary data
REG_DWORD =	4	&& 32bits int
ERROR_SUCCESS = 0	&& OK

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

FUNCTION ReadREG_SZ
   PARAMETERS  nKey, cSubKey, cValue
   #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      && Error Code returned from Registry functions
   LOCAL nKeyHandle    && Handle to Key that is opened in the Registry
   LOCAL lpdwValueType && Type of Value that we are looking for
   LOCAL lpbValue      && The data stored in the value
   LOCAL lpcbValueSize && Size of the variable
   LOCAL lpdwReserved  && Reserved Must be 0
    
   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