Winforms登录应用程序示例?

3

我很快将使用Winforms和Access开发一个时间管理应用程序,并正在寻找一些关于如何创建简单的密码保护应用程序的好资源。我来自asp.net,但对Winforms几乎没有经验。是否有针对此类应用程序的端到端教程?

谢谢大家。

1个回答

2

在VB.net中,你可以使用登录表单模板来创建一个登录表单。只需选择“添加/新建项目”,然后选择“登录表单”即可。

但是这只会创建一个带有两个文本框(用户名和密码)的对话框。每个人都可以做到这一点。

然后你需要自己决定如何验证输入的用户名和密码是否是有效用户,可以使用数据库、加密的文本文件、加密字符串存储在注册表中或者xml文件等方式进行验证。

在生成的表单中还有一些信息:

' TODO: Insert code to perform custom authentication using the

provided username and password ' (See http://go.microsoft.com/fwlink/?LinkId=35339).

' The custom principal can then be attached to the current thread's

principal as follows: ' My.User.CurrentPrincipal = CustomPrincipal ' where CustomPrincipal is the IPrincipal implementation used to perform authentication. ' Subsequently, My.User will return identity information encapsulated in the CustomPrincipal object ' such as the username, display name, etc.

如果你点击这个链接,你会跳转到这里:http://msdn.microsoft.com/en-us/library/aa302401.aspx。虽然它主要关注ASP.Net,但是请查看相关章节,因为它告诉你很多关于加密和其他有用的事情在这个领域。如果你只有一个运行在单用户模式下的应用程序,那么将用户和密码加密存储在注册表或本地xml文件中就足够了。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接