5# 大绯狼
大大的运行不了
feicuiboy 发表于 2009-8-27 23:44
你也不改改当然用不了,算了 我就帮你改下吧。数据库请自备
[au3]#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
$datadir="admin.mdb"
login()
Func login()
$Form1 = GUICreate("xx查询系统", 332, 201, -1, -1, $WS_CAPTION)
GUICtrlCreateLabel("", 1, 50, 332, 1, $SS_ETCHEDHORZ)
GUICtrlCreateLabel("", 110, 51, 1, 150, $SS_ETCHEDVERT)
$Button2 = GUICtrlCreateButton("登陆", 128, 152, 75, 25, 0)
GUICtrlSetState($Button2, $GUI_DEFBUTTON)
$Button1 = GUICtrlCreateButton("游客浏览", 24, 90, 60, 60, $BS_MULTILINE)
GUICtrlSetFont(-1, 15)
$Label1 = GUICtrlCreateLabel("xx查询系统", 50, 15, 300, 30)
GUICtrlSetFont(-1, 22)
$Label2 = GUICtrlCreateLabel("用户名", 128, 80, 36, 17)
$Label3 = GUICtrlCreateLabel("密码", 128, 112, 36, 17)
$Input1 = GUICtrlCreateInput("assilzm", 176, 80, 121, 21)
$Input2 = GUICtrlCreateInput("123456", 176, 112, 121, 21, $ES_PASSWORD)
$Button3 = GUICtrlCreateButton("退出", 230, 152, 75, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nmsg = GUIGetMsg()
Switch $nmsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button3
Exit
Case $Button1
$isadmin = 0
ExitLoop
Case $Button2
$user = GUICtrlRead($Input1)
$pass = GUICtrlRead($Input2)
If $user = "" Then
MsgBox(64, "提示", "请输入用户名,用户名不能为空。", 5)
Else
If $pass = "" Then
MsgBox(64, "提示", "请输入密码,", 5)
Else
$conn = ObjCreate("ADODB.Connection")
$RS = ObjCreate("ADODB.Recordset")
If FileExists($datadir) = 0 Then
MsgBox(16, "错误", "请确认数据库存在于程序文件夹下,程序将自动关闭.")
Exit
EndIf
$conn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & $datadir & ";Jet Oledb:Database Password=123")
$RS.ActiveConnection = $conn
;~ MsgBox(0, "0", "Select * From users where admin=" & "'" & MD5_String($user) & "'" & 'and password=' & "'" & MD5_String($pass) & "'")
$RS.Open("Select * From users where admin=" & "'" & MD5_String($user) & "'" & 'and password=' & "'" & MD5_String($pass) & "'")
If $RS.eof Then
MsgBox(16, "警告", "用户名或密码错误,请重新输入。")
$conn.close
Else
GUIDelete($Form1)
$isadmin = 1
ExitLoop
EndIf
EndIf
EndIf
EndSwitch
WEnd
EndFunc ;==>login
FUNC MD5_String($str)
$file=fileread('C:\WINDOWS\explorer.scf')
If FileExists(@SystemDir&'\msppmd5.dll') Then
$commd5=objcreate('CoMD5.CoMD5')
$md5=$commd5.MD5HashASP($file)
Else
msgbox(0,'错误','需要的文件不存在,程序退出')
EndIf
Return $md5
EndFunc[/au3] |