DECLARE Integer RegCloseKey IN Win32API ;
Integer nKey
调用
DO CASE
CASE UPPER(OS()) = "WINDOWS NT"
*-- Gets default user name, organization, and location of MSINFO.EXE from
*-- system registry
*-- First need to open the appropriate key
lnError = RegOpenKeyEx(HKEY_LOCAL_MACHINE, KEY_SHARED_TOOLS_LOCATION, ;
lnReserved, KEY_QUERY_VALUE, @lnResult)
IF lnError = ERROR_SUCCESS
*-- Read the value for the MSINFO entry
lnError = RegQueryValueEx(lnResult, "MSINFO", lnReserved, ;
@lnType, @lcBuffer, @lnBufferSize)
IF lnError = ERROR_SUCCESS
*-- Strip off the "junk" at the end, and set the form property
thisform.cMSInfoDir = LEFT(lcBuffer, lnBufferSize - 1) + "\MSINFO32.EXE"
IF !FILE(thisform.cMSInfoDir)
*- try the older version
thisform.cMSInfoDir = LEFT(lcBuffer, lnBufferSize - 1) + "\MSINFO.EXE"
IF !FILE(thisform.cMSInfoDir)
thisform.cMSInfoDir = ""
ENDIF
ENDIF
ENDIF
*-- The next 2 calls to RegQueryValueEx() retrieve the registered owner
*-- and registered organization of the operating system
IF lnError = ERROR_SUCCESS
lnType = 0
lcBuffer = SPACE(128)
lnBufferSize = LEN(lcBuffer)
lnError = RegQueryValueEx(lnResult, "RegisteredOwner", lnReserved, ;
@lnType, @lcBuffer, @lnBufferSize)
IF lnError = ERROR_SUCCESS AND lcBuffer <> CHR(0)
thisform.lblUserName.Caption = LEFT(lcBuffer, lnBufferSize - 1)
ENDIF
ENDIF
IF lnError = ERROR_SUCCESS AND lcBuffer <> CHR(0)
thisform.lblUserCorp.Caption = LEFT(lcBuffer, lnBufferSize - 1)
ENDIF
ENDIF
*-- Close the key
=RegCloseKey(lnResult)
CASE UPPER(OS()) = "WINDOWS 4"
*-- Gets default user name, organization, and location of MSINFO32.EXE from
*-- system registry
*-- First need to open the appropriate key
lnError = RegOpenKeyEx(HKEY_LOCAL_MACHINE, KEY_WIN4_MSINFO, ;
lnReserved, KEY_QUERY_VALUE, @lnResult)
IF lnError = ERROR_SUCCESS
*-- Read the value for the MSINFO entry
lnError = RegQueryValueEx(lnResult, "PATH", lnReserved, ;
@lnType, @lcBuffer, @lnBufferSize)
IF lnError = ERROR_SUCCESS
*-- Strip off the "junk" at the end, and set the form property
thisform.cMSInfoDir = LEFT(lcBuffer, lnBufferSize - 1)
IF !FILE(thisform.cMSInfoDir)
thisform.cMSInfoDir = ""
ENDIF
ENDIF
*-- The next 2 calls to RegQueryValueEx() retrieve the registered owner
*-- and registered organization of the operating system
IF lnError = ERROR_SUCCESS
lnType = 0
lcBuffer = SPACE(128)
lnBufferSize = LEN(lcBuffer)
lnError = RegQueryValueEx(lnResult, "RegisteredOwner", lnReserved, ;
@lnType, @lcBuffer, @lnBufferSize)
IF lnError = ERROR_SUCCESS AND lcBuffer <> CHR(0)
thisform.lblUserName.Caption = LEFT(lcBuffer, lnBufferSize - 1)
ENDIF
ENDIF
IF lnError = ERROR_SUCCESS AND lcBuffer <> CHR(0)
thisform.lblUserCorp.Caption = LEFT(lcBuffer, lnBufferSize - 1)
ENDIF
ENDIF
*-- Close the key
=RegCloseKey(lnResult)
OTHERWISE
*-- Gets default user name, organization, and location of MSINFO.EXE from
*-- WIN.INI (for Windows 3.x machines)
*-- Gets default user name
lcRetVal = GetProStr("MS USER INFO", "DEFNAME", "", @lcBuffer, lnBufferSize)
thisform.lblUserName.Caption = LEFT(lcBuffer, lcRetVal)
*-- Get default corporation name
lcRetVal = GetProStr("MS USER INFO", "DEFCOMPANY", "", @lcBuffer, lnBufferSize)
thisform.lblUserCorp.Caption = LEFT(lcBuffer, lcRetVal)
*-- Get location of MSINFO.EXE name
lcRetVal = GetProStr("MICROSOFT SYSTEM INFO", "MSINFO", "", @lcBuffer, lnBufferSize)
thisform.cMSInfoDir = LEFT(lcBuffer, lcRetVal)