软件登陆设计
本帖最后由 feicuiboy 于 2009-8-31 00:30 编辑关于软件登陆问题
问题一:
想制作一个软件登陆界面,
用户名,密码,然后判断,正确则运行下面的一段代码
错误则运行另外一段代码。
问题2:能否将原来的一个完整的AU3程序作为一个自定义函数。可以的话,该怎么来调用??
Func
****
EndFunc怎么调用
谢谢 顶起,高手解答下,。谢谢 用参数来启动程序 这样的登录界面吗? 自己以前写的,用ACCESS数据库,你用得着就拿去吧
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 4# 水木子
是的,就是这样的界面,密码在程序里面设置,不需要连接到远程的地址 5# 大绯狼
大大的运行不了{:3_86:} 5# 大绯狼
大大的运行不了{:3_86:}
feicuiboy 发表于 2009-8-27 23:44 http://www.autoitx.com/images/common/back.gif
你也不改改当然用不了,算了 我就帮你改下吧。数据库请自备
#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 8# 大绯狼
谢谢,可以用啦:face (6): 收藏了 学习下 正需要呢,谢谢分享,学习一下 回复 8# 大绯狼
太历害了!这么好的源码,要好好学习了 回复 8# 大绯狼
能不能改成加载本地的EXE来使用,我不会改,请大绯狼帮忙做一下实例! 回复 4# 水木子
水木子版主
这样的登录界面吗?
哪里有,找不到啊 楼上这位,你N个贴子都是挖坟贴,多少年前的东西全都被你挖出来了
页:
[1]
2