Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Windows Date
Message
 
À
04/05/2005 06:33:58
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Versions des environnements
Visual FoxPro:
VFP 6
OS:
Windows '98
Network:
Windows 98
Database:
Visual FoxPro
Divers
Thread ID:
01009567
Message ID:
01011138
Vues:
18
If the below will not work for you, try to find the proper name for the date in the registry. For Windows XP it is "InstallDate", for "my" Windows98 at the moment, it is "FirstInstallDateTime".
#DEFINE HKEY_LOCAL_MACHINE	-2147483646  
#DEFINE KEY_READ		131097

local hKey, retval,pcKey,InstallDate,FirstInstallDateTime

declare long RegCloseKey in ADVAPI32.DLL integer nHKey
declare long RegOpenKeyEx in ADVAPI32.DLL;
			integer nHKey, string cSubKey, integer nOptions, ;
			integer nAccess, integer @cResult
declare long RegQueryValueEx in ADVAPI32.DLL;
			integer nHKey, string cValueToGet, integer nReserved, ;
			integer @nType, string @cBufferData, integer @nBufferLen
			
hKey = 0
retval=OS(1)
IF "NT" $ retval OR retval="Windows 5."		&&NT, XP
	pcKey="Software\Microsoft\Windows NT\CurrentVersion"
ELSE
	pcKey="Software\Microsoft\Windows\CurrentVersion"
ENDIF

if RegOpenKeyEX(HKEY_LOCAL_MACHINE, pcKey, 0, KEY_READ, @hKey) == 0		&& Worked

	InstallDate	=	iGetKeyValue(hKey,"InstallDate","REG_DWORD")
	FirstInstallDateTime	=	iGetKeyValue(hKey,"FirstInstallDateTime","REG_DWORD")
	
	= RegCloseKey(hKey)
	
	retval = retval+CHR(13)+CHR(10)+CHR(13)+CHR(10)+;
		IIF(not "???"$InstallDate,InstallDate+CHR(13)+CHR(10),"")+;
		IIF(not "???"$FirstInstallDateTime,FirstInstallDateTime,"")
else
	retval = retval+CHR(13)+CHR(10)+CHR(13)+CHR(10)+;
			"NO information available  ????"
endif

=messagebox(retval)

Return
*-----------------------------
PROCEDURE iGetKeyValue
LPARAMETERS hKey, ValueName, pcType
LOCAL uDataType,nBufLen,cReturnData, retval
 
uDataType = 0
nBufLen = 254
cReturnData = space(nBufLen)
 
IF RegQueryValueEx(hKey, ValueName, 0, @uDataType, @cReturnData, @nBufLen) =0
	retval= trans(DATETIME(1970,1,1,0,0,0) + buf2dword(cReturnData))
ELSE
	retval="???"
ENDIF
RETURN ValueName+" "+retval
*------------------------------------
FUNCTION  buf2dword (lcBuffer)
RETURN;
    Asc(SUBSTR(lcBuffer, 1,1)) + ;
    Asc(SUBSTR(lcBuffer, 2,1)) * 256 +;
    Asc(SUBSTR(lcBuffer, 3,1)) * 65536 +;
    Asc(SUBSTR(lcBuffer, 4,1)) * 16777216
ENDFUNC
*----------------------------------------
>Dear Sir,
>
>The codes applies on in WindowsXP and do not work in Windows98.
>Please modify or suggest another.
>
>Thanks in advance
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform