Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [Setup]
- AppName=My Program
- AppVersion=1.5
- DefaultDirName={pf}\My Program
- [Code]
- const
- PwdURL = 'https://projects-stackoverflow-tlama.googlecode.com/svn/trunk/18070448/file1.txt';
- var
- InitialPassword: string;
- function TryGetTextFile(const URL: string; out Response: string): Boolean;
- var
- Request: Variant;
- begin
- Result := True;
- try
- Request := CreateOleObject('WinHttp.WinHttpRequest.5.1');
- OleCheck(Request.Open('GET', URL, False));
- OleCheck(Request.Send);
- Response := Request.ResponseText;
- except
- Result := False;
- Response := GetExceptionMessage;
- end;
- end;
- procedure InitializeWizard;
- var
- Response: string;
- begin
- // if downloading succeeded, assign the response to the InitialPassword
- if TryGetTextFile(PwdURL, Response) then
- InitialPassword := Response
- else
- begin
- // downloading failed, so let's take further actions, like setting up some
- // fallback password, showing error message, or e.g. exiting setup
- InitialPassword := 'Downloading failed, so let''s setup some fixed pwd.';
- MsgBox('Downloading of a password failed. ' + Response, mbError, MB_OK);
- end;
- end;
- function CheckPassword(Password: String): Boolean;
- begin
- // continue only if the entered password is not empty and equals to "MasterPassword" or
- // the one downloaded before (if downloading succeeded)
- Result := (Password <> '') and ((Password = 'MasterPassword') or (Password = InitialPassword));
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement