Use VB to get the time when the Windows system is installed (for NT, 2000, XP, ..)

xiaoxiao2021-03-05  31

Option expedition

Private Declare Function RegCreateKey Lib "advapi32.dll" Alias ​​"RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As LongPrivate Declare Function RegQueryValueEx Lib "advapi32.dll" Alias ​​"RegQueryValueExA" (ByVal hKey As Long, BYVAL LPVALUENAME AS STRING, BYVAL LPRESERVED AS Long, LPTYPE As Long, LPDATA AS ANY, LPCBDATA AS Long AS LongPrivate Declare Function Regclosekey LIB "Advapi32.dll" (Byval HKEY As Long) AS Long

Private const hkey_local_machine = & h80000002private const rag_dword = 4

Function GetWindowsNTInstallTime () As String On Error Resume Next Dim InstallDateValue As Long Dim hKey As Long Dim ret As String If RegCreateKey (HKEY_LOCAL_MACHINE, "SOFTWARE / Microsoft / Windows NT / CurrentVersion", hKey) = 0 Then If RegQueryValueEx (hKey, "InstallDate ", 0 &, REG_DWORD, 4) = 0 THEN RET = CSTR (InstallDateValue) End if HKEY THEN RegcloseKey HKEY End IF RET <>" "" 1970), "1970 -01-01 00:00 ") Else getWindowsntinstallTime =" Time unknown "end ifnd function

Private submmand1_click () msgbox "The current system installation time is:" & getWindowsntInstallTime, vbinformation, "" End Sub

'-------------------------------------------' Please indicate the source 'author: Don just fine' E-mail: tanaya@163.com '------------------------------------- --------

转载请注明原文地址:https://www.9cbs.com/read-33524.html

New Post(0)