---
Public Class Form1 Public Declare Auto Function LogonUser Lib "advapi32.dll" (ByVal lpszUsername As String, ByVal lpszDomain As String, ByVal lpszPassword As String, _ ByVal dwLogonType As Integer, ByVal dwLogonProvider As Integer, ByRef phToken As IntPtr) As Boolean Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub Private Sub Button_OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_OK.Click Dim UserID As String = TextBox_UserName.Text Dim UserPass As String = TextBox_Password.Text Dim bTemp As Boolean Dim MachineName As String MachineName = System.Environment.MachineName Const LOGON32_PROVIDER_DEFAULT As Integer = 0 Const LOGON32_LOGON_INTERACTIVE As Integer = 2 Dim tokenHandle As New IntPtr(0) tokenHandle = IntPtr.Zero bTemp = LogonUser(UserID, MachineName, UserPass, LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, tokenHandle) If bTemp Then MsgBox("登入成功") Else MsgBox("登入失敗") End If End SubEnd Class
沒有留言:
張貼留言