Anyone know how to do this.
Thanks in Advance,
Ed
HTH Pete
"Ed" <ebra...@selectqu.com> wrote in message
news:41d8...@newsgroups.borland.com...
Thanks,
Ed
"Pete Fraser" <pete....@frasersoft.nospam.com> wrote in message
news:41d966ca$1...@newsgroups.borland.com...
Well, it depends on the serving site. If it expects a request from an
authorized user, there could be a number of ways to authenticate.
It could use htaccess, post params, even get params, which wouldn't be
very secure, BTW.
I, personally, would need more info about the server or site that I am
getting the file from and what it is expecting.
If it is expecting htaccess authentication, I am not sure how to do that
but if it is expecting get/post param authentication, that is easy to do
using idHTTP.
"Ed" <ebra...@selectqu.com> wrote in message
news:41d98585$1...@newsgroups.borland.com...
And HostLane has their head in the sand!
Thanks for the help,
Ed
IE has closed the security loophole that allowed the
http://username:pass...@mysite.com. It doesn't work in
Firefox, either.
Using the WinInet functions pointed out by Mike Shklonik
should work for you.
If you need a full demo, let me know.
Thanks again,
Ed
"eshipman" <mr_delphi_developer@yahoo!!!.com> wrote in message
news:MPG.1c4460789...@forums.borland.com...
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,
Forms,
Dialogs, WinInet, ExtCtrls, StdCtrls, JPEG;
type
TForm1 = class(TForm)
Button1: TButton;
Image1: TImage;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure GetJpeg(AImage: TImage; AUserName, APassword, AURL:
String);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function GetFileWithUserPassword(AAppName, AUserName,
APassword, AURL: String): String;
const BufferSize = 1024;
var
Buffer: String;
BufferLen: DWORD;
hSession, hURL: HInternet;
bytesRead: DWORD;
s: String;
begin
Result:='';
hSession := InternetOpen(PChar(AAppName),
INTERNET_OPEN_TYPE_PRECONFIG or
INTERNET_OPEN_TYPE_PRECONFIG,
nil, nil, 0);
try
hURL := InternetConnect(hSession,
PChar(AURL),
INTERNET_DEFAULT_HTTP_PORT,
PChar(AUserName),
PChar(APassword),
INTERNET_SERVICE_HTTP,
0,
0);
if hURL <> nil then
begin
hURL := InternetOpenURL(hSession, PChar(AURL), nil,0,0,0);
try
s := '';
repeat
Buffer := '';
SetLength(Buffer, BufferSize);
InternetReadFile(hURL, PChar(Buffer), BufferSize, BufferLen);
SetLength(Buffer, BufferLen);
if (BufferLen <> 0) then
s := s + Buffer;
until (BufferLen = 0);
Result := s;
finally
InternetCloseHandle(hURL)
end;
end;
finally
InternetCloseHandle(hSession)
end;
end;
procedure TForm1.GetJpeg(AImage: TImage; AUserName, APassword, AURL:
String);
var
LStream: TStringStream;
LImage: TJpegImage;
s: String;
i: Integer;
begin
s := GetFileWithUserPassword(ExtractFileName(Application.ExeName),
AUserName,
APassword, AURL);
LStream := TStringStream.Create(s);
try
LImage := TJpegImage.create;
try
LImage.LoadFromStream(LStream);
AImage.picture.Assign(LImage);
finally
LImage.Free;
end;
finally
LStream.Free;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
GetJpeg(Image1, 'Me', 'MyPassword',
'http://www.austinmetrobaseball.com/images/googlesearch.jpg');
end;
end.
--
With best regards, Mike Shkolnik
E-mail: mshk...@scalabium.com
WEB: http://www.scalabium.com
"eshipman" <mr_delphi_developer@yahoo!!!.com> wrote in message
news:MPG.1c44a9968...@forums.borland.com...
Thanks,
Ed
Well, I guess I didn't read your post well enough, sorry...
just use the InternetWriteFile function instead InternetReadFile in posted
sample code
--
With best regards, Mike Shkolnik
E-mail: mshk...@scalabium.com
WEB: http://www.scalabium.com
"Ed" <ebra...@selectqu.com> wrote in message
news:41db...@newsgroups.borland.com...