QUOTE(bcff2002 @ 2004年09月09日 07时15分)
QUOTE(gnatix @ 2004年09月09日 01时35分)
呵呵,如果要真正防破解,用 Inno 当然是不合适的,这个以前已经说过了。Inno 这方面的功能即不是防小人,也不是防君子,算是好玩吧。
同意,所以把方法和脚本说一下,只当是学习一下了。
其实这个脚本的目的主要是演示如何按自己的愿望更改和调整安装程序的界面,而不是演示如何计算机器码和注册码。脚本中只是把硬盘序列号简单地转换为一个看上去有点复杂的机器码和注册码,这个可能简单得可笑。
再重复一次:Inno 这个功能是没有什么防破解能力的!再有:即使不运行安装程序,也是可以把安装包里的文件提取出来的。所以:如果你有值钱的软件要保护,不要指望 Inno 的这个功能!
CODE
; 脚本由 Inno Setup 脚本设计向导 创建。
; 有关创建 INNO SETUP 脚本的详情请查阅帮助文档!
[Setup]
UserInfoPage=true
DisableStartupPrompt=yes
DirExistsWarning=no
CreateAppDir=no
DisableProgramGroupPage=yes
Uninstallable=no
AppName=安装示例
AppVerName=安装示例
DefaultDirName={pf}\安装示例
[MESSAGES]
UserInfoSerial=注册码(&R):
[INI]
Filename: "{app}\hanzify.url"; Section: "InternetShortcut"; Key: "URL"; String: "http://www.hanzify.org"
[Run]
Filename: "{app}\hanzify.url"; Description: "访问汉化新世纪主页"; Flags: postinstall shellexec unchecked
[UninstallDelete]
Type: files; Name: "{app}\hanzify.url"
[Code]
var HDSerial: LongInt;
function GetVolumeInformation(
lpRootPathName: PChar;
lpVolumeNameBuffer: PChar;
nVolumeNameSize: LongInt;
var lpVolumeSerialNumber: LongInt;
lpMaximumComponentLength: LongInt;
lpFileSystemFlags : LongInt;
lpFileSystemNameBuffer: PChar;
nFileSystemNameSize: LongInt ) : Integer;
external 'GetVolumeInformationA@kernel32.dll stdcall';
function GetLastError( ): Integer;
external 'GetLastError@kernel32.dll stdcall';
procedure RegURLOnClick(Sender: TObject);
var
tmp: Integer;
begin
InstShellExec('http://bbs.hanzify.org', '', '', SW_SHOWNORMAL, tmp);
end;
function GenMachineID(SerialNum: LongInt): String;
var
SN: LongInt;
MID, tmp1, tmp2: string;
begin
// 生成机器码
if SerialNum > 567890123 then
SN:= SerialNum-567890123
else
SN:= 567890123-SerialNum;
tmp1:= IntToStr(SN);
while length(tmp1)>3 do
begin
tmp2:= copy(tmp1,1,3);
delete(tmp1,1,3);
MID:= MID+Chr(65+StrToInt(tmp2)*26/999)+tmp2;
end;
MID:= MID+Chr(65+StrToInt(tmp1)*26/999)+tmp1;
tmp1:= MID;
MID:= '';
while length(tmp1)>3 do
begin
tmp2:= copy(tmp1,1,3);
delete(tmp1,1,3);
MID:= MID+tmp2+'-';
end;
MID:= MID+tmp1;
If SerialNum > 567890123 then
MID:='6J7-'+MID
else
MID:='V94-'+MID;
result:= MID;
end;
function GenRegCode(SerialNum: LongInt): String;
var MID,tmp1,tmp2: string;
SN: LongInt;
begin
// 生成注册码
if SerialNum > 432109876 then
SN:= SerialNum-432109876
else
SN:= 432109876-SerialNum;
MID:='';
tmp1:= IntToStr(SN);
while length(tmp1)>3 do
begin
tmp2:= copy(tmp1,1,3);
delete(tmp1,1,3);
MID:= MID+Chr(65+StrToInt(tmp2)*26/999)+tmp2;
end;
MID:= MID+Chr(65+StrToInt(tmp1)*26/999)+tmp1;
tmp1:= MID;
MID:= '';
while length(tmp1)>3 do
begin
tmp2:= copy(tmp1,1,3);
delete(tmp1,1,3);
MID:= MID+tmp2+'-';
end;
MID:= MID+tmp1;
If SerialNum > 432109876 then
MID:='3P6-'+MID
else
MID:='X5B-'+MID;
result:= MID;
end;
procedure InitializeWizard();
begin
WizardForm.USERINFOSERIALLABEL.top := WizardForm.USERINFOORGLABEL.top+
2*(WizardForm.USERINFOORGLABEL.top - WizardForm.USERINFONAMELABEL.top);
WizardForm.USERINFOSERIALEDIT.top := WizardForm.USERINFOORGEDIT.top+
2*(WizardForm.USERINFOORGEDIT.top - WizardForm.USERINFONAMEEDIT.top);
WizardForm.USERINFOSERIALLABEL.Font.Color := clRed;
end;
procedure curpagechanged(curpage: integer);
var
IDLabel, RegAdr, RegURL: TLabel;
IDEdit: TEdit;
RefDisk, DiskLabel: String;
begin
if curpage=wpUserInfo then
begin
if DirExists('C:\') then
RefDisk:= 'C:\'
else
RefDisk:= 'D:\';
DiskLabel:= ' ';
GetVolumeInformation(RefDisk, DiskLabel, 15, HDSerial, 0, 0, '', 0);
IDLabel:= TLabel.Create(WizardForm);
IDLabel.parent:= WizardForm.USERINFONAMELABEL.parent;
IDLabel.top:= WizardForm.USERINFONAMELABEL.top+
2*(WizardForm.USERINFOORGLABEL.top - WizardForm.USERINFONAMELABEL.top);
IDLabel.left:= WizardForm.USERINFOSERIALLABEL.left;
IDLabel.autosize:= true;
IDLabel.font.color:= clRed;
IDLabel.caption:= '机器码:';
RegAdr:= TLabel.Create(WizardForm);
RegAdr.parent:= WizardForm.USERINFONAMELABEL.parent;
RegAdr.top:= WizardForm.USERINFOSERIALLABEL.top+
(WizardForm.USERINFOORGLABEL.top - WizardForm.USERINFONAMELABEL.top)-7;
RegAdr.left:= WizardForm.USERINFOSERIALLABEL.left + 220;
RegAdr.autosize:= true;
RegAdr.caption:= '注册地址:';
RegURL:= TLabel.Create(WizardForm);
RegURL.parent:= WizardForm.USERINFONAMELABEL.parent;
RegURL.top:= RegAdr.top;
RegURL.left:= RegAdr.left + 60;
RegURL.autosize:= true;
RegURL.caption:= 'http://bbs.hanzify.org';
RegURL.Font.Style := RegURL.Font.Style + [fsUnderLine];
RegURL.Font.Color := clBlue;
RegURL.Cursor := crHand;
RegURL.OnClick := @RegURLOnClick;
IDEdit:= TEdit.Create(WizardForm);
IDEdit.parent:= WizardForm.USERINFONAMEEDIT.parent;
IDEdit.top:= WizardForm.USERINFONAMEEDIT.top+
2*(WizardForm.USERINFOORGEDIT.top - WizardForm.USERINFONAMEEDIT.top);
IDEdit.left:= WizardForm.USERINFOSERIALEDIT.left;
IDEdit.width:= WizardForm.USERINFOSERIALEDIT.width;
IDEdit.readonly:= true;
IDEdit.color:= clGray;
IDEdit.text := GenMachineID(HDSerial);
end;
end;
function CheckSerial(Serial: string): Boolean;
begin
result:= (Serial=GenRegCode(HDSerial)) or (UpperCase(Serial)='WWW.HANZIFY.ORG');
end;