我现写了一软件,不知如何加密,请各位高手帮助解决。(200分)

  • 主题发起人 dragonstar
  • 开始时间
D

dragonstar

Unregistered / Unconfirmed
GUEST, unregistred user!
我现写了一软件,不知如何加密,请各位高手帮助解决。
一我想让软件有使用次数限制
二如何给软件加注册号,不注册软件不能使,用户不同注册号不同。
 
1。使用次数限制: 你可以把使用信息写到注册表中,程序启动的时候就从注册表中检查一次
用户使用次数加一,当达到一定的数值你就告诉他已经到了应该使用的次数,请注册等(不过
需要把你的键值放在合适的位置,不然...)。
2。软件注册号的问题:
可以通过读用户的机器号。如硬盘号等(有唯一标识的东东),然后根据这些号编一个算法
就是用户的注册号了.
如 用户号:硬盘号或别的号等(程序运行以后,让用户发给你)
注册号:根据硬盘号通过算法计算出来的号码(计算以后你自己发给用户,)
当然算法肯定是你自己设计了。不然就没有一点意义了。
 
不如用加密狗省事
 
最好的取硬盘序列号加密,我用的就是这个方法
这样用户电脑升级也注册码也不会重新向你要
这是我的截取序列号转字符串的过程。
var
DSSER,dsser1,dsser2,dsser3:string;
mp,i,lc:integer;
a1,s:array [0..25] of string;
SerialNum : dword;
aX, bX : dword;
Buffer : array [0..255] of char;
begin
CSER:='';
while CSER=''do
begin
IF GetVolumeInformation('c:/', Buffer, SizeOf(Buffer), @SerialNum, aX, bX, nil, 0) then
CSER:=IntToStr(SerialNum);
end;
....加密算法...//此部分省略
end;

 
加密狗适用于商业软件,如果是自己开发的共享软件,要放在网上的话,还是改注册表吧
 
这是我很久以前写得程序,语法书写不规范,凑合着看吧!
原理是这样的,程序每次运行时就检测硬盘出厂号。然后有个注册程序,运行后显示硬盘
出厂号,当然客户看到的是“生成注册号”。这样就算是他的系统重装了,也可自行注册
,在程序运行前,出现注册窗口时输入该号就可以的。

unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, Menus, ToolWin, ExtCtrls, StdActns, ActnList, ImgList,
DB,shellapi, DBTables, ADODB;
type
TSrbIoControl = packed record
HeaderLength : ULONG;
Signature : Array[0..7] of Char;
Timeout : ULONG;
ControlCode : ULONG;
ReturnCode : ULONG;
Length : ULONG;
end;
SRB_IO_CONTROL = TSrbIoControl;
PSrbIoControl = ^TSrbIoControl;
TIDERegs = packed record
bFeaturesReg : Byte;
// Used for specifying SMART "commands".
bSectorCountReg : Byte;
// IDE sector count register
bSectorNumberReg : Byte;
// IDE sector number register
bCylLowReg : Byte;
// IDE low order cylinder value
bCylHighReg : Byte;
// IDE high order cylinder value
bDriveHeadReg : Byte;
// IDE drive/head register
bCommandReg : Byte;
// Actual IDE command.
bReserved : Byte;
// reserved. Must be zero.
end;
IDEREGS = TIDERegs;
PIDERegs = ^TIDERegs;
TSendCmdInParams = packed record
cBufferSize : DWORD;
irDriveRegs : TIDERegs;
bDriveNumber : Byte;
bReserved : Array[0..2] of Byte;
dwReserved : Array[0..3] of DWORD;
bBuffer : Array[0..0] of Byte;
end;
SENDCMDINPARAMS = TSendCmdInParams;
PSendCmdInParams = ^TSendCmdInParams;
TIdSector = packed record
wGenConfig : Word;
wNumCyls : Word;
wReserved : Word;
wNumHeads : Word;
wBytesPerTrack : Word;
wBytesPerSector : Word;
wSectorsPerTrack : Word;
wVendorUnique : Array[0..2] of Word;
sSerialNumber : Array[0..19] of Char;
wBufferType : Word;
wBufferSize : Word;
wECCSize : Word;
sFirmwareRev : Array[0..7] of Char;
sModelNumber : Array[0..39] of Char;
wMoreVendorUnique : Word;
wDoubleWordIO : Word;
wCapabilities : Word;
wReserved1 : Word;
wPIOTiming : Word;
wDMATiming : Word;
wBS : Word;
wNumCurrentCyls : Word;
wNumCurrentHeads : Word;
wNumCurrentSectorsPerTrack : Word;
ulCurrentSectorCapacity : ULONG;
wMultSectorStuff : Word;
ulTotalAddressableSectors : ULONG;
wSingleWordDMA : Word;
wMultiWordDMA : Word;
bReserved : Array[0..127] of Byte;
end;
PIdSector = ^TIdSector;
const
IDE_ID_FUNCTION = $EC;
IDENTIFY_BUFFER_SIZE = 512;
DFP_RECEIVE_DRIVE_DATA = $0007c088;
IOCTL_SCSI_MINIPORT = $0004d008;
IOCTL_SCSI_MINIPORT_IDENTIFY = $001b0501;
DataSize = sizeof(TSendCmdInParams)-1+IDENTIFY_BUFFER_SIZE;
BufferSize = SizeOf(SRB_IO_CONTROL)+DataSize;
W9xBufferSize = IDENTIFY_BUFFER_SIZE+16;
type
Tmain = class(TForm)
ToolBar1: TToolBar;
ToolButton1: TToolButton;
ToolButton2: TToolButton;
ImageList1: TImageList;
ActionList1: TActionList;
WindowCascade1: TWindowCascade;
WindowTileVertical1: TWindowTileVertical;
WindowTileHorizontal1: TWindowTileHorizontal;
WindowMinimizeAll1: TWindowMinimizeAll;
WindowArrange1: TWindowArrange;
xtwh: TAction;
sys: TAction;
MainMenu1: TMainMenu;
D1: TMenuItem;
N2: TMenuItem;
C1: TMenuItem;
N6: TMenuItem;
N8: TMenuItem;
V1: TMenuItem;
N19: TMenuItem;
N20: TMenuItem;
W1: TMenuItem;
N13: TMenuItem;
N14: TMenuItem;
N15: TMenuItem;
N16: TMenuItem;
N17: TMenuItem;
N18: TMenuItem;
N4: TMenuItem;
N27: TMenuItem;
N26: TMenuItem;
N11: TMenuItem;
N22: TMenuItem;
N12: TMenuItem;
StatusBar1: TStatusBar;
Timer1: TTimer;
ToolButton4: TToolButton;
T1: TMenuItem;
N1: TMenuItem;
ToolButton6: TToolButton;
ToolButton7: TToolButton;
ToolButton9: TToolButton;
ToolButton10: TToolButton;
ToolButton11: TToolButton;
ToolButton12: TToolButton;
ToolButton13: TToolButton;
ToolButton15: TToolButton;
ToolButton16: TToolButton;
ToolButton17: TToolButton;
ToolButton18: TToolButton;
ToolButton19: TToolButton;
ToolButton20: TToolButton;
ToolButton21: TToolButton;
ToolButton22: TToolButton;
help: TAction;
xkylr: TAction;
hgcx: TAction;
fpkj: TAction;
jc: TAction;
bbdy: TAction;
About: TAction;
N5: TMenuItem;
kycj: TAction;
ToolButton3: TToolButton;
ADOConnection1: TADOConnection;
tab_tk: TADOTable;
reg: TADOTable;
czy: TADOTable;
procedure FormShow(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure N19Click(Sender: TObject);
procedure N20Click(Sender: TObject);
procedure ToolButton20Click(Sender: TObject);
procedure sysExecute(Sender: TObject);
procedure xkylrExecute(Sender: TObject);
procedure fpkjExecute(Sender: TObject);
procedure hgcxExecute(Sender: TObject);
procedure bbdyExecute(Sender: TObject);
procedure jcExecute(Sender: TObject);
procedure xtwhExecute(Sender: TObject);
procedure AboutExecute(Sender: TObject);
procedure FormDblClick(Sender: TObject);
procedure helpExecute(Sender: TObject);
procedure kycjExecute(Sender: TObject);
private
{ Private declarations }
function ExistsForm(MDIFormCaption:String): boolean;
public
{ Public declarations }
end;

var
main: Tmain;
implementation
uses Unit1,unit3,unit4,unit5,unit9,unit10,unit11,unit8, Unit12,unit6,unit15,unit19,
Unit17;
{$R *.dfm}
procedure ChangeByteOrder( var Data;
Size : Integer );
var ptr : PChar;
i : Integer;
c : Char;
begin
ptr := @Data;
for i := 0 to (Size shr 1)-1do
begin
c := ptr^;
ptr^ := (ptr+1)^;
(ptr+1)^ := c;
Inc(ptr,2);
end;
end;

function GetIdeDiskSerialNumber : String;
var
hDevice : THandle;
cbBytesReturned : DWORD;
pInData : PSendCmdInParams;
pOutData : Pointer;
// PSendCmdOutParams
Buffer : Array[0..BufferSize-1] of Byte;
srbControl : TSrbIoControl absolute Buffer;
begin
Result := '';
FillChar(Buffer,BufferSize,#0);
if Win32Platform=VER_PLATFORM_WIN32_NT then
begin
// Windows NT, Windows 2000
// Get SCSI port handle
hDevice := CreateFile( '//./Scsi0:',
GENERIC_READ or GENERIC_WRITE,
FILE_SHARE_READ or FILE_SHARE_WRITE,
nil, OPEN_EXISTING, 0, 0 );
if hDevice=INVALID_HANDLE_VALUE then
Exit;
try
srbControl.HeaderLength := SizeOf(SRB_IO_CONTROL);
System.Move('SCSIDISK',srbControl.Signature,8);
srbControl.Timeout := 2;
srbControl.Length := DataSize;
srbControl.ControlCode := IOCTL_SCSI_MINIPORT_IDENTIFY;
pInData := PSendCmdInParams(PChar(@Buffer)
+SizeOf(SRB_IO_CONTROL));
pOutData := pInData;
with pInData^do
begin
cBufferSize := IDENTIFY_BUFFER_SIZE;
bDriveNumber := 0;
with irDriveRegsdo
begin
bFeaturesReg := 0;
bSectorCountReg := 1;
bSectorNumberReg := 1;
bCylLowReg := 0;
bCylHighReg := 0;
bDriveHeadReg := $A0;
bCommandReg := IDE_ID_FUNCTION;
end;
end;
if not DeviceIoControl( hDevice, IOCTL_SCSI_MINIPORT,
@Buffer, BufferSize, @Buffer, BufferSize,
cbBytesReturned, nil ) then
Exit;
finally
CloseHandle(hDevice);
end;
end
else
begin
// Windows 95 OSR2, Windows 98
hDevice := CreateFile( '//./SMARTVSD', 0, 0, nil,
CREATE_NEW, 0, 0 );
if hDevice=INVALID_HANDLE_VALUE then
Exit;
try
pInData := PSendCmdInParams(@Buffer);
pOutData := @pInData^.bBuffer;
with pInData^do
begin
cBufferSize := IDENTIFY_BUFFER_SIZE;
bDriveNumber := 0;
with irDriveRegsdo
begin
bFeaturesReg := 0;
bSectorCountReg := 1;
bSectorNumberReg := 1;
bCylLowReg := 0;
bCylHighReg := 0;
bDriveHeadReg := $A0;
bCommandReg := IDE_ID_FUNCTION;
end;
end;
if not DeviceIoControl( hDevice, DFP_RECEIVE_DRIVE_DATA,
pInData, SizeOf(TSendCmdInParams)-1, pOutData,
W9xBufferSize, cbBytesReturned, nil ) then
Exit;
finally
CloseHandle(hDevice);
end;
end;
with PIdSector(PChar(pOutData)+16)^do
begin
ChangeByteOrder(sSerialNumber,SizeOf(sSerialNumber));
SetString(Result,sSerialNumber,SizeOf(sSerialNumber));
end;
end;

function TMain.ExistsForm(MDIFormCaption:String):boolean;
var
i:byte;
begin
result:=true;
for i:=0 to MDIChildCount-1do
begin
if MDIChildren.Caption=MDIFormCaption
then
result:=false;
end;
end;

procedure Tmain.FormShow(Sender: TObject);
begin
if trim(reg.Fields[1].asstring)='' then
begin
application.MessageBox('系统与数据源出现重大错误,请速与开发商联系!','系统警告',MB_ok+MB_Iconstop);
close;
end
else
begin
if StrToInt('$'+reg.Fields[1].asstring)<=strtoint(formatdatetime('yyyymmdd',now)) then
begin
application.MessageBox('系统与数据源出现重大错误,请速与开发商联系!','系统警告',MB_ok+MB_Iconstop);
close;
end
else
begin
if TRIM(GetIdeDiskSerialNumber)<>trim(reg.Fields[0].asstring) then
begin
form17.showmodal;
end else
form1.showmodal;
end;
end;
end;

procedure Tmain.FormCreate(Sender: TObject);
begin
height:=600;
width:=800;
end;

procedure Tmain.Timer1Timer(Sender: TObject);
begin
StatusBar1.Panels[0].Text:='当前用户:'+userna;
StatusBar1.Panels[1].Text:=datetostr(date);
StatusBar1.Panels[3].Text:=application.hint;
StatusBar1.Panels[2].Text:=timetostr(time);
end;

procedure Tmain.N19Click(Sender: TObject);
begin
N19.Checked:=not N19.Checked;
if N19.Checked then
ToolBar1.Visible:=True else
ToolBar1.Visible:=False;
end;

procedure Tmain.N20Click(Sender: TObject);
begin
N20.Checked:=not N20.Checked;
if N20.Checked then
StatusBar1.Visible:=True else
StatusBar1.Visible:=False;
end;

procedure Tmain.ToolButton20Click(Sender: TObject);
begin
close;
end;

procedure Tmain.sysExecute(Sender: TObject);
begin
if ExistsForm('题库维护') then
begin
Application.CreateForm(Tform3, form3);
form3.show;
end else
form3.show;
end;

procedure Tmain.xkylrExecute(Sender: TObject);
begin
if ExistsForm('新考员录入') then
begin
Application.CreateForm(Tform4, form4);
form4.show;
end else
form4.show;
end;

procedure Tmain.fpkjExecute(Sender: TObject);
begin
if ExistsForm('新考员分配考机') then
begin
Application.CreateForm(Tform5, form5);
form5.show;
end else
form5.show;
end;

procedure Tmain.hgcxExecute(Sender: TObject);
begin
if ExistsForm('多功能查询') then
begin
Application.CreateForm(Tform9, form9);
form9.show;
end else
form9.show;
end;

procedure Tmain.bbdyExecute(Sender: TObject);
begin
if ExistsForm('报表打印') then
begin
Application.CreateForm(Tform11, form11);
form11.show;
end else
form11.show;
end;

procedure Tmain.jcExecute(Sender: TObject);
begin
if ExistsForm('考机监测') then
begin
Application.CreateForm(Tform10, form10);
form10.show;
end else
form10.show;
end;

procedure Tmain.xtwhExecute(Sender: TObject);
begin
if ExistsForm('系统维护') then
begin
Application.CreateForm(Tform6, form6);
form6.show;
end else
form6.show;
end;

procedure Tmain.AboutExecute(Sender: TObject);
begin
aboutbox.showmodal;
end;

procedure Tmain.FormDblClick(Sender: TObject);
begin
if strtoint(jb)=1 then
begin
if ExistsForm('考员管理系统') then
begin
Application.CreateForm(Tform15, form15);
form15.show;
end else
form15.show;
end;
end;

procedure Tmain.helpExecute(Sender: TObject);
begin
ShellExecute(Handle, 'open', 'help/help.chm', nil, nil, SW_SHOW);
end;

procedure Tmain.kycjExecute(Sender: TObject);
begin
if ExistsForm('考员成绩查看') then
begin
Application.CreateForm(Tform19, form19);
form19.show;
end else
form19.show;
end;

end.
 
我现写了一软件,不知如何加密,请各位高手帮助解决。
一我想让软件有使用次数限制
二如何给软件加注册号,不注册软件不能使,用户不同注册号不同。
请各位说出详细的办法。
 
先加密数据库,再检索BIOS,读取第一次安装时的硬件,生成注册号,
还有对时间加密,写函数,演示说明,QQ:11171025.
 
接受答案了.
 

Similar threads

顶部