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
相关文档:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Xml;
namespace WebApplication2
{
/// <summary>
/// XMLHelper XML文档操作管理器
&nb ......
第一种
<%=RetInfo("DB","数据库") %>
<%=RetInfo("YX_UpFile","上传文件") %>
<%=RetfileInfo("Include/", "广告")%>
//从前台调用后台方法
//从前台调用后台的方法..并向其方法传入不同的参数!
第二种
<ItemTemplate >
<%#Ret_stat(Convert.ToInt16(Eval("YX_Stat1")), "热点")%>
......
今天用到这个,网上找个不错的,保存下来。
注意:这个方法是快速关机,不会保存你的任何未保存信息。
// 这个结构体将会传递给API。使用StructLayout
[StructLayout(LayoutKind.Sequential, Pack = 1)]
internal struct TokPriv1Luid
{
public int Count;
public ......
发生这种问题主要是没有将typelib信息写到注册表,只要调用RegisterTypeLibServer函数则可添加相关信息,参考下面代码。
以下宏定义是我为了简化com控件开发定义的。
//-----------------------------------------------------------------
//EXPORTS
//
//DllGetClassObject PRI ......