首页 > 开发 > 综合 > 正文

软件注册码方面的应用和本地化的加密

2024-07-21 02:21:01
字体:
来源:转载
供稿:网友
using system;
using system.io;
using system.runtime.interopservices;
using system.text;
using microsoft.win32;

namespace wjb.readorwriteiniandreg
{
/// <summary>
/// harddiskval 的摘要说明。
/// 读取指定盘符的硬盘序列号
/// 类库开发:吴剑冰
/// 时间:2003年10月20日
/// 功能:读取指定盘符的硬盘序列号
/// </summary>
public class harddiskval
{
[dllimport("kernel32.dll")]
private static extern int getvolumeinformation(
string lprootpathname,
string lpvolumenamebuffer,
int nvolumenamesize,
ref int lpvolumeserialnumber,
int lpmaximumcomponentlength,
int lpfilesystemflags,
string lpfilesystemnamebuffer,
int nfilesystemnamesize
);
/// <summary>
/// 获得盘符为drvid的硬盘序列号,缺省为c
/// </summary>
/// <param name="drvid"></param>
/// <returns></returns>
public string hdval(string drvid)
{
const int max_filename_len = 256;
int retval = 0;
int a =0;
int b =0;
string str1 = null;
string str2 = null;

int i = getvolumeinformation(
drvid + @":/",
str1,
max_filename_len,
ref retval,
a,
b,
str2,
max_filename_len
);

return retval.tostring();
}
public string hdval()
{
const int max_filename_len = 256;
int retval = 0;
int a =0;
int b =0;
string str1 = null;
string str2 = null;

int i = getvolumeinformation(
"c://",
str1,
max_filename_len,
ref retval,
a,
b,
str2,
max_filename_len
);

return retval.tostring();
}
}
}
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表