📄 share_unit.pas
字号:
unit Share_Unit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,
StdCtrls, Registry;
function GetVolumeNumber: string; //得到硬盘卷标号
function GetZCH(sn: string): string; //生成注册号
procedure WriteReg(sn,reg : string); //写注册表
procedure WriteLoginTimes(LoginTimes: string); //回写登录次数
function GetLoginTimes: string; //得到登录次数
implementation
function GetVolumeNumber: string; //得到硬盘卷标号
var
VolumeSerialNumber: DWORD;
MaximumComponentLength: DWORD;
FileSystemFlags: DWORD;
SerialNumber: string;
begin
GetVolumeInformation('c:\', nil, 0, @VolumeSerialNumber, MaximumComponentLength, FileSystemFlags, nil, 0);
Result := inttohex(VolumeSerialNumber, 2);
end;
function GetZCH(sn: string): string; //生成注册号
var
TmpStr: string;
i: integer;
begin
TmpStr := Trim(sn);
for i := 1 to Length(TmpStr) do
begin
case TmpStr[i] of
'A': TmpStr[i] := '1';
'B': TmpStr[i] := '6';
'C': TmpStr[i] := 'F';
'D': TmpStr[i] := '8';
'E': TmpStr[i] := '6';
'F': TmpStr[i] := '7';
'1': TmpStr[i] := 'A';
'2': TmpStr[i] := '8';
'3': TmpStr[i] := 'E';
'4': TmpStr[i] := '6';
'5': TmpStr[i] := '5';
'6': TmpStr[i] := 'B';
'7': TmpStr[i] := '3';
'8': TmpStr[i] := 'C';
'9': TmpStr[i] := 'F';
end;
end;
Result := TmpStr;
end;
procedure WriteReg(sn,reg : string); //写注册表
var
MyReg: TRegistry;
begin
try
Myreg := TRegistry.Create;
MyReg.RootKey := HKEY_LOCAL_MACHINE;
MyReg.OpenKey('Software\FLy\Reg', True);
MyReg.WriteString('sn', sn);
MyReg.WriteString('reg', reg);
finally
MyReg.CloseKey;
MyReg.Free;
end;
end;
procedure WriteLoginTimes(LoginTimes: string); //回写剩余登录次数到注册表
var
MyReg: TRegistry;
begin
try
Myreg := TRegistry.Create;
MyReg.RootKey := HKEY_LOCAL_MACHINE;
MyReg.OpenKey('Software\FLy\LoginTimes', False);
MyReg.WriteString('LoginTimes', LoginTimes);
finally
MyReg.CloseKey;
MyReg.Free;
end;
end;
function GetLoginTimes: string; //获取注册表的登录次数
var
MyReg: TRegistry;
LoginTimes: string;
begin
try
Myreg := TRegistry.Create;
MyReg.RootKey := HKEY_LOCAL_MACHINE;
MyReg.OpenKey('Software\FLy\LoginTimes', True);
LoginTimes := MyReg.ReadString('LoginTimes');
Result := LoginTimes;
if (LoginTimes = '') or (StrToIntDef(LoginTimes,0) > 100) then
begin
MyReg.WriteString('LoginTimes', '100');
LoginTimes := MyReg.ReadString('LoginTimes');
Result := LoginTimes;
end;
finally
MyReg.CloseKey;
MyReg.Free;
end;
end;
end.
//此源码由程序太平洋收集整理发布,任何人都可自由转载,但需保留本站信息
//╭⌒╮┅~ ¤ 欢迎光临程序太平洋╭⌒╮
//╭⌒╭⌒╮╭⌒╮~╭⌒╮ ︶ ,︶︶
//,︶︶︶︶,''︶~~ ,''~︶︶ ,''
//╔ ╱◥███◣═╬╬╬╬╬╬╬╬╬╗
//╬ ︱田︱田 田 ︱ ╬
//╬ http://www.5ivb.net ╬
//╬ ╭○╮● ╬
//╬ /■\/■\ ╬
//╬ <| || 有希望,就有成功! ╬
//╬ ╬
//╚╬╬╬╬╬╬╬╬╬╬╗ ╔╬╬╬╬╝
//
//说明:
//专业提供VB、.NET、Delphi、ASP、PB源码下载
//包括:程序源码,控件,商业源码,系统方案,开发工具,书籍教程,技术文档
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -