c#简单操作注册表
一、首先先添加引用 using Microsoft.Win32;
//因为操作注册表的两个类RegistryKey和Registry都包含在此引用中;
二、编写代码开始操作注册表
1、 #region 限制软件的使用次数
private void BtnTimes_Click(object sender, EventArgs e)
{
try
{
//在注册表中创建子键
RegistryKey rk = Registry.LocalMachine.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\Currentversion\\Run\\nums"); //CreateSubKey打开和创建两种功能
int numscount = (int)rk.GetValue("nums", 0); //读取注册表中软件使用次数
if (numscount >= 10)
{
MessageBox.Show("不好意思,你是非注册用户,只能免费使用十次,请注册!", "系统提示", MessageBoxButtons.OK,MessageBoxIcon.Warning);
rk.Close(); //关闭注册表
this.Close(); //退出程序
}
&n
相关文档:
public sealed class DbOper
{
///<summary>
/// DbOper类的构造函数
///</summary>
private DbOper()
{
}
......
//命名空间 using Microsoft.Win32;
private void checkBox2_CheckedChanged(object sender, System.EventArgs e)
{
if (checkBox2.Checked) //设置开机自启动
{
//MessageBox.Show ("设置开机自启动需要修改注册表","提示");
string path = Application.ExecutablePath;
RegistryKey rk = Registry.LocalMac ......
OleDbConnection conn = null;
try
{
`string strConn;
&n ......
C# CHM帮助文档生成工具-Sandcastle
为了让我们的开发团队规范文档,并易于交流,最终使用了Sandcastle生成chm格式文档。
一、下载。
我发现有两种Sandcastle可供下载,一个是官方的Sandcastle,另一个是SandcastleGUI(图形界面的)。
前一个是必须安装的,然后再下载个SandcastleGUI,直接使用即可,下载地址为:
......