sebastian
sebastian

Reputation: 897

INNO setup serial number validating failing?

Im trying to validate the serial number entered by the user on server side with the help of webservice,,, when the user enters the serial key and clicks the next button, the serial number should be validated..i used the code below for that....the name of my method that validates the serial number is ValidateKey()....and im passing a static value 123456 for that method and service will return false for this value,,,,but my installation is proceeding further and im getting the alert messagebox at the last step of my installation

function ValidateSerialNumber: Boolean;
var
  WinHttpReq: Variant;
begin
  WinHttpReq := CreateOleObject('WinHttp.WinHttpRequest.5.1');
  WinHttpReq.Open('POST', 'http://localhost:1024/WebService1/Service.asmx?op=ValidateMe', False);
  WinHttpReq.Send('123456');

  if WinHttpReq.Status <> 200 then
  begin
    Result := False;
  end
  else
  begin
    Result := True;
  end;
end;

function NextButtonClick(CurPageID: Integer): Boolean;
begin
  Result := True;

  if CurPageID = SerialPage.ID then
  begin
    Result := ValidateSerialNumber;
  end;
end;

here i want to installation to stop when the user clicks the next button if the service returns false, if the service returns true then he can go further with the installation, where am i going wrong?

Upvotes: 2

Views: 895

Answers (1)

TLama
TLama

Reputation: 76713

You need to validate that serial number from the NextButtonClick event method. To stay on your custom page if the validation fails assign False value to the Result variable. If you want to let the wizard continue, assign True to the Result of that event method. Something like this:

function ValidateSerialNumber(const SerialNumber: string): Boolean;
var
  WinHttpReq: Variant;
begin
  Result := False;

  WinHttpReq := CreateOleObject('WinHttp.WinHttpRequest.5.1');
  WinHttpReq.Open('POST', 'http://localhost:1024/WebService1/Service.asmx?op=ValidateMe', False);
  WinHttpReq.Send(SerialNumber);

  Result := WinHttpReq.Status = 200;
end;

function NextButtonClick(CurPageID: Integer): Boolean;
var
  SerialNumber: string;
begin
  Result := True;

  if CurPageID = SerialPage.ID then
  begin
    SerialNumber := GetSerialNumber('-');
    Result := ValidateSerialNumber(SerialNumber);
  end;
end;

Upvotes: 1

Related Questions