如何在c#.net中只使用一次表单 [英] how to use one form only one time in c#.net

查看:88
本文介绍了如何在c#.net中只使用一次表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用产品密钥工具制作了ac#应用程序,有两个表单,一个名为ProductKey,另一个名为Home。



当我运行时这个表格然后转到产品密钥页面,在验证产品密钥后,它转到主页,当我重新运行此应用程序时,它再次显示产品密钥页。

但是我想在验证后当我重新运行这个应用程序然后它将直接转到主页。

i made a c# application with product key facility and there are two forms one is named "ProductKey" and another one is "Home" .

when i run this form then it go to product key page and after verification of product key it go to home page and when i re-run this application it again show the product key page.
but i want that after verification of product key when i re-run this application then it will directly go to home page.

推荐答案

每个应用程序都有一个入口点 - 在Windows窗体应用程序的情况下是主要的方法......

你的代码中有这样的地方:

every application has an entry point - in case of Windows Form Application this is the Main method...
You have somewhere in your code code like this:
static void Main ( )
{
  // some code here
  Application.Run( new ProductKey( ) );
}



此时你应该这样做:

1.检查你是否已经拥有有效的产品密钥(来自注册表) / web service / config file)

2.如果打开'Home'

3.如果不打开'ProductKey'(在该表单中存储验证结果在注册表中/ web service / config file)


At this point you should do these:
1. Check if you already has a valid product key (from registry/web service/config file)
2. If do open 'Home'
3. If do not open 'ProductKey' (In that form store result of validation in registry/web service/config file)


为了完成这样的任务,您需要持久已经显示ProductKey表单的信息。例如,请参阅演练:持久化对象(C#和Visual Basic) [ ^ ]。
In order to accomplish such a task you need to persist the info that your "ProductKey" form has been already shown. See, for instance "Walkthrough: Persisting an Object (C# and Visual Basic)"[^].


这篇关于如何在c#.net中只使用一次表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆