找回密码
 加入
搜索
查看: 3930|回复: 15

软件登陆设计

[复制链接]
发表于 2009-8-18 19:37:27 | 显示全部楼层 |阅读模式
本帖最后由 feicuiboy 于 2009-8-31 00:30 编辑

关于软件登陆问题
问题一:
想制作一个软件登陆界面,
用户名,密码,然后判断,正确则运行下面的一段代码

错误则运行另外一段代码。

问题2:能否将原来的一个完整的AU3程序作为一个自定义函数。可以的话,该怎么来调用??
Func
****
EndFunc  怎么调用

谢谢
 楼主| 发表于 2009-8-27 19:14:47 | 显示全部楼层
顶起,高手解答下,。谢谢
发表于 2009-8-27 19:50:21 | 显示全部楼层
用参数来启动程序
发表于 2009-8-27 20:48:33 | 显示全部楼层
这样的登录界面吗?

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2009-8-27 20:58:11 | 显示全部楼层
自己以前写的,用ACCESS数据库,你用得着就拿去吧
[au3]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[/au3]

评分

参与人数 2金钱 +50 贡献 +54 收起 理由
kn007 + 50 + 49
lynfr8 + 5

查看全部评分

 楼主| 发表于 2009-8-27 23:37:38 | 显示全部楼层
4# 水木子

是的,就是这样的界面,密码在程序里面设置,不需要连接到远程的地址
 楼主| 发表于 2009-8-27 23:44:18 | 显示全部楼层
5# 大绯狼


大大的运行不了
发表于 2009-8-28 11:19:05 | 显示全部楼层
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]
 楼主| 发表于 2009-8-28 13:24:13 | 显示全部楼层
8# 大绯狼

谢谢,可以用啦
发表于 2009-8-30 09:39:56 | 显示全部楼层
收藏了   学习下
发表于 2015-7-2 23:06:33 | 显示全部楼层
正需要呢,谢谢分享,学习一下
发表于 2016-12-17 14:02:34 | 显示全部楼层
回复 8# 大绯狼


    太历害了!这么好的源码,要好好学习了
发表于 2017-3-12 13:25:02 | 显示全部楼层
回复 8# 大绯狼


    能不能改成加载本地的EXE来使用,我不会改,请大绯狼帮忙做一下实例!
发表于 2017-3-12 13:32:01 | 显示全部楼层
回复 4# 水木子


  水木子版主  
这样的登录界面吗?

哪里有,找不到啊
发表于 2017-3-13 10:14:16 | 显示全部楼层
楼上这位,你N个贴子都是挖坟贴,多少年前的东西全都被你挖出来了
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-3-29 14:00 , Processed in 0.090707 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表