獲取系統帳戶密碼週期的例項
在介面上新增一2個lable,1個textbox,1個button.程式碼如下:
Option Explicit
Private Const NERR_SUCCESS As Long = 0&
Private Type USER_INFO_1
usri1_name As Long
usri1_password As Long
usri1_password_age As Long
usri1_priv As Long
usri1_home_dir As Long
usri1_comment As Long
usri1_flags As Long
usri1_script_path As Long
End Type
Private Declare Function NetUserGetInfo Lib "Netapi32" _
(Servername As Byte, _
Username As Byte, _
ByVal Level As Long, _
Buffer As Long) As Long
Private Declare Function NetApiBufferFree Lib "Netapi32" _
(ByVal Buffer As Long) As Long
Private Declare Sub CopyMemory Lib "Kernel32" _
Alias "RtlMoveMemory" _
(pTo As Any, _
uFrom As Any, _
ByVal lSize As Long)
Private Sub Form_Load()
With Label1
.Caption = "The password for"
.AutoSize = True
.Move 200, 400
End With
With Text1
.Text = "(enter a user name)"
.Move 1550, 360, 1600, 285
End With
With Label2
.Caption = "is xxxxxxx days old"
.AutoSize = True
.Move 3200, 400
End With
With Command1
.Caption = "Get Password Age"
.Move 1500, 800, 1600
End With
End Sub
Private Sub Command1_Click()
'if sServer is "" use the local machine
Label2.Caption = "is " & GetPasswordAge("", Text1.Text) & " days old"
End Sub
Private Function GetPasswordAge(sServer As String, _
sUser As String) As Single
Dim buff As Long
Dim bServer() As Byte
Dim bUser() As Byte
Dim ui1 As USER_INFO_1
bUser = sUser & vbNullChar
bServer = vbNullChar
If NetUserGetInfo(bServer(0), bUser(0), 1, buff) = NERR_SUCCESS Then
CopyMemory ui1, ByVal buff, Len(ui1)
GetPasswordAge = (ui1.usri1_password_age / 86400)
End If
NetApiBufferFree buff
End Function
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9437124/viewspace-1016751/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- SAP系統預設的管理員帳戶和密碼密碼
- Linux 控制系統帳戶過期Linux
- 出現作業系統錯誤 1330(此帳戶的密碼已過期。)作業系統密碼
- 光貓超級帳號密碼,重置光貓獲取超級帳號密碼密碼
- Nacos - 客戶端例項列表獲取客戶端
- 檢驗系統帳號是否存在的例項
- javascript獲取當前電腦系統時間程式碼例項JavaScript
- jquery獲取瀏覽器客戶區尺寸程式碼例項jQuery瀏覽器
- js獲取瀏覽器客戶區尺寸程式碼例項JS瀏覽器
- Flutter生命週期的獲取Flutter
- Win10系統怎麼重置Microsoft帳戶密碼【圖文教程】Win10ROS密碼
- JavaScript獲取星期程式碼例項JavaScript
- 通過PowerShell獲取Windows系統密碼HashWindows密碼
- jquery獲取元素高度程式碼例項jQuery
- js獲取瀏覽器版本作業系統等資訊程式碼例項JS瀏覽器作業系統
- Vue例項及生命週期Vue
- vue例項以及生命週期Vue
- js獲取指定單元格的內容程式碼例項例項JS
- jQuery獲取指定的li元素程式碼例項jQuery
- js獲取事件的型別程式碼例項JS事件型別
- javascript獲取元素的順序程式碼例項JavaScript
- jQuery獲取視窗尺寸的例項程式碼jQuery
- Vue例項的生命週期鉤子Vue
- javascript獲取客戶端ip地址省市和運營商程式碼例項JavaScript客戶端
- javascript獲取視窗大小例項程式碼JavaScript
- javascript獲取主機域名程式碼例項JavaScript
- js獲取當前月份例項程式碼JS
- js獲取事件源物件程式碼例項JS事件物件
- jquery獲取同輩元素程式碼例項jQuery
- js獲取主機域名程式碼例項JS
- javascript獲取元素封裝程式碼例項JavaScript封裝
- javascript獲取url引數程式碼例項JavaScript
- React獲取元件例項React元件
- jQuery獲取指定元素的父元素程式碼例項jQuery
- css獲取指定元素的兄弟元素程式碼例項CSS
- jquery獲取元素的標籤tagName程式碼例項jQuery
- 獲取指定區間的li元素程式碼例項
- js獲取元素的實際尺寸程式碼例項JS