用VB得到windows系统安装时的时间(for NT,2000,XP,..)
2005-04-21 11:27
543 查看
Option Explicit
Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private 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 Long
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Const HKEY_LOCAL_MACHINE = &H80000002
Private Const REG_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, InstallDateValue, 4) = 0 Then
ret = CStr(InstallDateValue)
End If
If hKey Then RegCloseKey hKey
End If
If ret <> "" Then
GetWindowsNTInstallTime = DateAdd("s", CLng(ret), "1970-01-01 00:00")
Else
GetWindowsNTInstallTime = "时间未知"
End If
End Function
Private Sub Command1_Click()
MsgBox "当前系统的安装时间为:" & GetWindowsNTInstallTime, vbInformation, ""
End Sub
'-------------------------------------------
' 转载请注明出处
' 作者:唐细刚
' 邮箱:tanaya@163.com
'-------------------------------------------
Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private 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 Long
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Const HKEY_LOCAL_MACHINE = &H80000002
Private Const REG_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, InstallDateValue, 4) = 0 Then
ret = CStr(InstallDateValue)
End If
If hKey Then RegCloseKey hKey
End If
If ret <> "" Then
GetWindowsNTInstallTime = DateAdd("s", CLng(ret), "1970-01-01 00:00")
Else
GetWindowsNTInstallTime = "时间未知"
End If
End Function
Private Sub Command1_Click()
MsgBox "当前系统的安装时间为:" & GetWindowsNTInstallTime, vbInformation, ""
End Sub
'-------------------------------------------
' 转载请注明出处
' 作者:唐细刚
' 邮箱:tanaya@163.com
'-------------------------------------------
相关文章推荐
- 用VB得到windows系统安装时的时间(for NT,2000,XP,..)
- [Windows系统安装]PE/2000/XP/2003/Vista/2008/7/8/8.1Pre版本
- Windows NT/2000系统中如何获取系统的启动时间
- Windows NT/2000系统中如何获取系统的启动时间(zz)
- 让Windows 2000/XP系统自动登陆
- Windows 2000/XP/2003下安装配置IIS+PHP+MySQL+Zend Optimizer+GD库+phpMyAdmin
- XP 系统下安装Windows 7(用硬盘全新安装)
- 在 SQL Server 2000 中对链接服务器运行分布式事务在您安装 Windows Server 2003 或 Windows XP Service Pack 2 时可能收到 7391 错误信息
- XP系统硬盘安装Windows 7
- 安装MySQL 时,系统提示:Cannot create windows service for mysql.error:0
- Windows 2000/XP/2003下安装配置IIS+PHP+MySQL+Zend Optimizer+GD库+phpMyAdmin
- 苹果机上安装双系统 (Mac+Windows XP)步骤
- Thinkpad R61I 驱动下载及安装方法 for windows XP
- 让Windows 2000/XP启动时自动登录系统
- iWay Service Manager 5.6 for Windows NT安装
- Thinkpad X61驱动下载及安装方法 for windows XP
- XP 系统下安装Windows 7(用硬盘全新安装)
- 在WINDOWS下和DOS(硬盘安装)下实现全自动安装XP系统的方法
- IIS 5.1 完整安装包 for Windows XP SP3
- Windows系统安装时间