0

这是我的 inno 设置脚本(inno 设置密钥生成器脚本)

我想自动设置输入查询到mac地址和私钥并且不可编辑。

inno 安装密钥生成器下载 (sample2.iky, ISID.dll)

www.mjfreelancing.com/index.php?option=com_content&view=article&id=11&Itemid=13

inno 安装程序下载

www.jrsoftware.org/isdl.php

图片1 http://i49.tinypic.com/nbodif.jpg

图2 http://i49.tinypic.com/22iaub.jpg

对不起我的英语不好

请帮帮我

谢谢


   [_ISTool]
EnableISX=true
Use7zip=false

[Files]
Source: sample2.iky; DestDir: {tmp}; Flags: ignoreversion


Source: ISID.dll; DestDir: {sys}\ISID; Flags: ignoreversion




[Setup]
AppName=Inno Key Generator2
AppVerName=Inno Key Generator 1.0.2.1 2
DefaultDirName={pf}\MJ Freelancing\IKG
InfoBeforeFile=readme.txt
DefaultGroupName=Inno Key Generator
OutputDir=output
AppCopyright=Copyright © Oct 2002 - 2006 MJ Freelancing
OutputBaseFilename=IKGSetup

[ThirdParty]
CompileLogMethod=append

[Code]


function ValidateSerialNumber(InnoKeyFile, User, Orgn, ProdCode, HDD, MAC, PrivateKey, Serial: AnsiString): Boolean;
external 'ValidateSerialNumber@files:ISID.dll stdcall';
function GetMACAddress(output: AnsiString): Boolean;
external 'GetMACAddress@files:ISID.dll stdcall'; 

var
    UserPage: TInputQueryWizardPage;
    UserValues: TArrayOfString;


procedure InitializeWizard();
begin

    { create the custom page }
    UserPage := CreateInputQueryPage(wpInfoBefore,      //wpWelcome,
        'Enter Registration Details', 'You need to be a registered user to be able to proceed',
        'Enter your registration details exactly (case sensitive), then click Next.');

    UserPage.Add('MAC Address:', true);
    UserPage.Add('Unlock Code:', False);
    UserPage.Add('Private Key:', False);


    { Set default values }
    SetArrayLength(UserValues, 3);
    RegQueryStringValue(HKLM, 'Software\Microsoft\Windows\Hitman', 'Hitman', UserValues[0]);
    RegQueryStringValue(HKLM, 'Software\Microsoft\Windows\Hitman', 'Hitman', UserValues[1]);
    if (UserValues[0] = '') and (UserValues[1] = '') then begin
        RegQueryStringValue(HKCU, 'Software\Microsoft\ND\User2', 'md', UserValues[0]);
        RegQueryStringValue(HKCU, 'Software\Microsoft\ND\User2', 'MD2', UserValues[1]);
    end;


    { Try to find the settings that were stored last time (also see below). }
    UserPage.Values[0] := GetPreviousData('MAC', UserValues[0]);
    UserPage.Values[1] := GetPreviousData('Unlock', UserValues[1]);
    UserPage.Values[2] := GetPreviousData('Private', UserValues[2]);


end;


procedure RegisterPreviousData(PreviousDataKey: Integer);
begin
  { Store the settings so we can restore them next time }

  SetPreviousData(PreviousDataKey, 'MAC', UserPage.Values[0]);
  SetPreviousData(PreviousDataKey, 'Unlock', UserPage.Values[1]);
  SetPreviousData(PreviousDataKey, 'Private', UserPage.Values[2]);

end;



function ScriptDlgPages(CurPage: Integer; BackClicked: Boolean): Boolean;
var
    ExpPath: String;

begin

    Result := True;

    if (CurPage = UserPage.ID) then
    begin
        ExtractTemporaryFile('sample2.iky');        { the public key file }

        ExpPath := ExpandConstant('{tmp}\sample2.iky');

        Result := False;

        UserValues[0] := UserPage.Values[0];
        UserValues[1] := UserPage.Values[1];
        UserValues[2] := UserPage.Values[2];



        if (UserValues[0] = '') or (UserValues[1] = '') or (UserValues[2] = '') then
            MsgBox('No fields can be blank !', mbError, MB_OK)
        else
        begin

        //UserPage.Values[0] := GetPreviousData('MAC', UserValues[0]);
        //UserPage.Values[1] := GetPreviousData('Unlock', UserValues[1]);
        //UserPage.Values[2] := GetPreviousData('Private', UserValues[2]);

    //function ValidateSerialNumber(InnoKeyFile, User,           Orgn,    PCe,HDD,MAC,PrivateKey, Serial: AnsiString): Boolean;
            Result := ValidateSerialNumber( ExpPath,'','','','',UserValues[0],UserValues[2],UserValues[1] );




if (not Result) then
                MsgBox('Invalid Entry !', mbError, MB_OK);

        end
    end

end;




function NextButtonClick(CurPage: Integer): Boolean;
begin
  Result := ScriptDlgPages(CurPage, False);
end;


function BackButtonClick(CurPage: Integer): Boolean;
begin
  Result := True;//ScriptDlgPages(CurPage, True);
end;


function HasHtmlHelp(): Boolean;
begin
    { HHCTRL.OCX GUID }
    Result := RegValueExists(HKCR, 'CLSID\{4662DAB0-D393-11D0-9A56-00C04FB68B66}\InprocServer32', '');
end;


function HasNoHtmlHelp(): Boolean;
begin
    Result := not HasHtmlHelp;
end;

4

2 回答 2

0

要使编辑框不可编辑,只需使用它们的属性 ReadOnly。

您已经创建了 3 个编辑框(TPPasswordEdit 类),所以现在只需将它们的 ReadOnly 设置为 true:

UserPage.Values[0].ReadOnly := True;
UserPage.Values[1].ReadOnly := True;
UserPage.Values[2].ReadOnly := True;

将此代码放在过程 InitializeWizard() 的末尾。

于 2013-05-08T05:52:03.020 回答
0
function GetMacAddress(output:string): Integer;
external 'GetMACAddress@files:ISID.dll stdcall';

//在它创建这个函数之后

function GetMacAdd(Output: string): string;
var
ClassName: String;
Ret: Integer;
begin
SetLength(ClassName, 256); 
Ret := GetMacAddress(PChar(ClassName)); 
Result := Copy(ClassName, 1 , Ret);
end;

//并调用它

UserPage.Values[0]:=(GetMACAdd(''));

希望能帮助到你。

于 2014-07-06T12:55:00.253 回答