给软件增加注册功能 c#
1.软件注册类
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Management;
using System.IO;
using System.Diagnostics;
using System.Configuration; namespace Text2Excel.Helper
{
public static class SoftRegister
{
private static string SoftVersion = "V02";//v0.1
private static string SoftMD5 = string.Empty;
private static string DiskVolume = string.Empty;
private static string CPUSerialNum = string.Empty;
private static string PublicKey = "<RSAKeyValue><Modulus>kkrIPGLqt2CUSeSLC3l4lgJzLuBt0GGwTI7Jqt9SbHmj8Kaz5ffPbHY3aibx4jF8bmWlyNiO8LTc2qL6CV1mCL599mStYhIdePElE9+WxniSc3YCCzKxpTnWjRL7ROA25fQPJghAWUiWva7VamwjF0rLHDgX+rcuGF7LScY49B0=</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>";
private static string getDiskVolume()
{
//ManagementClass mc = new ManagementClass("win32_NetworkAdapterConfiguration");
ManagementObject disk = new ManagementObject("win32_logicaldisk.deviceid=\"c:\"");
disk.Get();
return disk.GetPropertyValue("VolumeSerialNumber").ToString();
}
private static string getCPUserialNum()
{
string strCpu = null;
ManagementClass myCpu = new ManagementClass("win32_Processor");
ManagementObjectCollection myCpuCollection = myCpu.GetInstances();
foreach (ManagementObject myObject in myCpuCollection)
{
strCpu = myObject.Properties["Processorid"].Value.ToString();
}
return strCpu;
}
private static string getSoftMD5()
{
string fileName = System.Windows.Forms.Application.ExecutablePath;
try
{
FileStream file = new FileStream(fileName, FileMode.Open, FileAccess.Read);
System.Security.Cryptography.MD5 md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
byte[] retVal = md5.ComputeHash(file);
file.Close(); StringBuilder sb = new StringBuilder();
for (int i = ; i < retVal.Length; i++)
{
sb.Append(retVal[i].ToString("x2"));
}
return sb.ToString().ToUpper();
}
catch (Exception ex)
{
throw new Exception("GetMD5HashFromFile() fail,error:" + ex.Message);
}
}
public static void killMyself()
{
string bat = string.Format("@echo off \n ping -n 3 127.0.0.1 \n del {0}", System.Windows.Forms.Application.ExecutablePath);
File.WriteAllText("killme.bat", bat);
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = "killme.bat";
psi.Arguments = "\"" + Environment.GetCommandLineArgs()[] + "\"";
psi.WindowStyle = ProcessWindowStyle.Hidden;
Process.Start(psi);
System.Environment.Exit();
//Application.Exit();
}
public static bool meIsMe(){
if (getSoftMD5().Substring(,) == SoftMD5)
{
return true;
}
else
{
return false;
}
}
public static string getMNum()
{
if (SoftMD5 == string.Empty)
{
SoftMD5 = getSoftMD5();
}
if (DiskVolume == string.Empty)
{
DiskVolume = getDiskVolume();
}
if (string.IsNullOrEmpty(CPUSerialNum))
{
CPUSerialNum = getCPUserialNum();
}
string strNum = SoftVersion + SoftMD5.Substring(, ) + CPUSerialNum.Substring(, ) + DiskVolume.Substring(, );
return strNum;//18个注册字符
}
public static bool toRegist(string cipher)
{
try
{
if (CryptionHelper.VerifySigned(getMNum(), cipher, PublicKey))
{
return true;
}
else
{
return false;
}
}
catch (Exception e)
{
LogHelper.WriteLog(e);
return false;
} }
public static void updateConfig(string name, string value)
{
Configuration cfa = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
cfa.AppSettings.Settings[name].Value = value;
cfa.Save();
ConfigurationManager.RefreshSection("appSettings");
}
}
}
给软件增加注册功能 c#的更多相关文章
- python实现软件的注册功能(机器码+注册码机制)
http://www.cnblogs.com/cquptzzq/p/5940583.html 一.前言: 目的:完成已有python图像处理工具的注册功能 功能:用户运行程序后,通过文件自动检测认证状 ...
- Winform 注册机通用软件注册功能之建立有效的软件保护机制
本文转载:http://www.cnblogs.com/umplatform/archive/2013/01/23/2873001.html 众所周知,一些共享软件往往提供给使用者的是一个功能不受限制 ...
- C# 实现软件注册功能
相信很多初学编程的人都会对这个注册功能很感兴趣,我也不例外,刚学asp.net时,竞找不到这方面的实例,结果自己参考微软的一些文档自己做了一个,其实我做的这个注册功能很简单,读取计算机的CPU序列号, ...
- windows 增加右键功能 -->用命令行打开
windows 增加右键功能 -->用命令行打开 实现 注册表 以管理员权限CMD 到指定文件夹 Windows Registry Editor Version 5.00 [HKEY_CLASS ...
- C# 给软件加注册码功能
为自己写的程序加一个注册功能吧.生成的机器号是根据CPU和硬盘号来的,根据自己的需求改成是否是随机生成. 代码直接粘贴到新建类覆盖原代码就能直接用了. using System; using Syst ...
- apktool给软件加注册机修改图标和文件名
功能实现,即让你的软件具有注册机功能,或者破解别人的软件,据为己有! 先反编译文件包 然后全局工具,修改图标和名称 加注册机,输入key,下载计算器,即可.给某个用户设置自定义的使用时间!
- Java Spring+Mysql+Mybatis 实现用户登录注册功能
前言: 最近在学习Java的编程,前辈让我写一个包含数据库和前端的用户登录功能,通过看博客等我先是写了一个最基础的servlet+jsp,再到后来开始用maven进行编程,最终的完成版是一个 Spri ...
- BBS-基于forms组件和ajax实现注册功能
http://www.cnblogs.com/yuanchenqi/articles/7638956.html 1.设计注册页面 views.py from django import forms c ...
- 使用 Flask 框架写用户登录功能的Demo时碰到的各种坑(五)——实现注册功能
使用 Flask 框架写用户登录功能的Demo时碰到的各种坑(一)——创建应用 使用 Flask 框架写用户登录功能的Demo时碰到的各种坑(二)——使用蓝图功能进行模块化 使用 Flask 框架写用 ...
随机推荐
- HIVE快速入门
(一)简单入门 1.创建一个表 create table if not exists ljh_emp( name string, salary float, gender string) commen ...
- jquery节点查询
jQuery.parent(expr) //找父元素 jQuery.parents(expr) //找到所有祖先元素,不限于父元素 jQuery.children ...
- angularjs——工具方法
1.fromJson 把json字符串转成JSON对象 var jsonStr='[{"Name":"abc","age":12},{&qu ...
- Win7下部署 .NET MVC网站 之 HTTP错误 403.14-Forbidden 解决方法
今天在 IIS 7 发布MVC 站点时 遇到 ”HTTP错误 403.14-Forbidden Web 服务器被配置为不列出此目录的内容 “ 的错误提示. 一番折腾后发现在web.config 中加入 ...
- Asp.Net页面生命周期--转发(学海无涯)
一.什么是Asp.Net页面生命周期 当我们在浏览器地址栏中输入网址,回车查看页面时,这时会向服务器端(IIS)发送一个request请求,服务器就会判断发送过来的请求页面, 完全识别 HTTP 页 ...
- C程序设计语言练习题1-1
练习1-1 在你自己的系统中运行"hello, world"程序.再有意去掉程序中的部分内容,看看会得到什么出错信息. 代码如下: #include <stdio.h> ...
- GO不支持数组通过函数参数更改,有点不一样
package main import "fmt" func modify(array []int) { array[] = fmt.Println("In modify ...
- FJ省队集训DAY4 T1
直接上题解 #include<cstdio> #include<iostream> #include<cmath> #include<cstring> ...
- 解决MVC项目中,静态html 未找到时候,404的跳转
using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using ...
- Android SDK 下载速度慢解决方法
Mac 本搞Android开发,遇到Android SDK 下载速度慢,解决方法大概有两种.第一,FQ.这种方法比较彻底,但是要想有稳定的效果还的要花大价钱.第二,有些高人直接给了SDK中各软件的下载 ...