Posted by webmaster Guido on July 12, 2003 In Reply to: Send Login and Password to URL posted by JB on July
12, 2003 Let's set up a form with 3 Edit boxes: - edLogin: for the login; The code for the OnClick event of the button for accessing a password protected webpage is as follows: procedure TForm1.btnLoginClick(Sender: TObject); var Login, Password, WebPage, LogText: string; Return: integer; begin Login := edLogin.Text; Password :=edPassword.Text; WebPage := edPage.Text; LogText := 'http://' + Login + ':' + Password + '@' + Webpage; Return := ShellExecute(Handle, 'open', PChar(LogText), nil, nil, SW_SHOW); // If Return > 32 then it's OK, otherwise there was an error // For values of Return, see: API help, ShellExecute if Return > 32 then lblReturn.Caption := 'OK, done' else lblReturn.Caption := IntToStr(Return); end;Example: to access http://www.test.com with the login "abc" and the password '123', you would enter this in the edit-boxes: - edLogin: abc NOTE: add "SHELLAPI" to the USES statement of the form, otherwise Delphi won't find the ShellExecute function.
Find related articles Search for: shellexecute Delphi Forum :: Tutorials :: Source code :: Tips |
|