So habe ich das bei meiner Freeware "Christian Computer Radio" gemacht...
Delphi-Quellcode:
var
FileStream : TFileStream;
FileNeme :
String;
// <= C:\test.mp3
function Get_AppPath :
string;
begin
result:= ExtractFilePath( ParamStr( 0 ) );
end;
procedure StatusProc(buffer: Pointer; len, user: DWORD);
stdcall;
begin
if (buffer <>
nil)
and (len = 0)
then
SendMessage(win, WM_INFO_UPDATE, 8, DWORD(PChar(buffer)));
if (FileNeme = '
')
then
exit;
if (FileStream =
nil)
then
FileStream:= TFileStream.Create(FileNeme, fmCreate);
// create the file
if (buffer =
nil)
then
FileStream.Free
// finished downloading
else
FileStream.
Write(buffer^, len);
end;
function OpenURL(
url: PChar): Integer;
var ....
begin
FileNeme:= Get_AppPath + Form1.Filename_Edit.Text;
...
end;
procedure TForm1.StopClick(Sender: TObject);
begin
FreeAndNil(FileStream);
end;