怎么用程序实现。
下载如:
http://www.xxx.com/down.asp?downid=1
用IE打开这个就会提示自动下载保存的位置。
我自己在软件中
把这个下载到自己的目录中。
并且原文件名和他的文件相同。
我用了TNMHTTP。不行啊。
如果直接是http://www.xxx.com/abc.exe
就可以。

解决方案 »

  1.   

    像FLASHGET一样。
    输入这样的地址他都可以下载的!自己先顶一下。
      

  2.   

    不能吧!
    他应该在对应的Down.asp中建立了对应的下载地址!除非你的程序能智能的分析别人的down.asp的代码!
      

  3.   

    我也没找到合适的例子
    不过从网上找了一个用ftp下载文件的例子或许有帮助 共同研究吧:
    uses 
    WinInet, ComCtrls;function FtpDownloadFile(strHost, strUser, strPwd: string;Port: Integer; ftpDir, ftpFile, TargetFile: string; ProgressBar: TProgressBar): Boolean;function FmtFileSize(Size: Integer): string;beginif Size >= $F4240 thenResult := Format('%.2f', [Size / $F4240]) + ' Mb'elseif Size < 1000 thenResult := IntToStr(Size) + ' bytes'elseResult := Format('%.2f', [Size / 1000]) + ' Kb';end;constREAD_BUFFERSIZE = 4096; // or 256, 512, ...varhNet, hFTP, hFile: HINTERNET;buffer: array[0..READ_BUFFERSIZE - 1] of Char;bufsize, dwBytesRead, fileSize: DWORD;sRec: TWin32FindData;strStatus: string;LocalFile: file;bSuccess: Boolean;beginResult := False;{ Open an internet session }hNet := InternetOpen('Program_Name', // AgentINTERNET_OPEN_TYPE_PRECONFIG, // AccessTypenil, // ProxyNamenil, // ProxyBypass0); // or INTERNET_FLAG_ASYNC / INTERNET_FLAG_OFFLINE{Agent contains the name of the application orentity calling the Internet functions}
    { See if connection handle is valid }if hNet = nil thenbeginShowMessage('Unable to get access to WinInet.Dll');Exit;end;{ Connect to the FTP Server }hFTP := InternetConnect(hNet, // Handle from InternetOpenPChar(strHost), // FTP serverport, // (INTERNET_DEFAULT_FTP_PORT),PChar(StrUser), // usernamePChar(strPwd), // passwordINTERNET_SERVICE_FTP, // FTP, HTTP, or Gopher?0, // flag: 0 or INTERNET_FLAG_PASSIVE0);// User defined number for callbackif hFTP = nil thenbeginInternetCloseHandle(hNet);ShowMessage(Format('Host "%s" is not available',[strHost]));Exit;end;{ Change directory }bSuccess := FtpSetCurrentDirectory(hFTP, PChar(ftpDir));if not bSuccess thenbeginInternetCloseHandle(hFTP);InternetCloseHandle(hNet);ShowMessage(Format('Cannot set directory to %s.',[ftpDir]));Exit;end;{ Read size of file }if FtpFindFirstFile(hFTP, PChar(ftpFile), sRec, 0, 0) <> nil thenbeginfileSize := sRec.nFileSizeLow;// fileLastWritetime := sRec.lastWriteTimeend elsebeginInternetCloseHandle(hFTP);InternetCloseHandle(hNet);ShowMessage(Format('Cannot find file ',[ftpFile]));Exit;end;{ Open the file }hFile := FtpOpenFile(hFTP, // Handle to the ftp sessionPChar(ftpFile), // filenameGENERIC_READ, // dwAccessFTP_TRANSFER_TYPE_BINARY, // dwFlags0); // This is the context used for callbacks.if hFile = nil thenbeginInternetCloseHandle(hFTP);InternetCloseHandle(hNet);Exit;end;{ Create a new local file }AssignFile(LocalFile, TargetFile);{$i-}Rewrite(LocalFile, 1);{$i+}if IOResult <> 0 thenbeginInternetCloseHandle(hFile);InternetCloseHandle(hFTP);InternetCloseHandle(hNet);Exit;end;dwBytesRead := 0;bufsize := READ_BUFFERSIZE;while (bufsize > 0) dobeginApplication.ProcessMessages;if not InternetReadFile(hFile,@buffer, // address of a buffer that receives the dataREAD_BUFFERSIZE, // number of bytes to read from the filebufsize) then Break; // receives the actual number of bytes readif (bufsize > 0) and (bufsize <= READ_BUFFERSIZE) thenBlockWrite(LocalFile, buffer, bufsize);dwBytesRead := dwBytesRead + bufsize;{ Show Progress }ProgressBar.Position := Round(dwBytesRead * 100 / fileSize);Form1.Label1.Caption := Format('%s of %s / %d %%',[FmtFileSize(dwBytesRead),FmtFileSize(fileSize) ,ProgressBar.Position]);end;CloseFile(LocalFile);InternetCloseHandle(hFile);InternetCloseHandle(hFTP);InternetCloseHandle(hNet);Result := True;end;
      

  4.   

    我在写一办公自动化程序
    在写文档的上传和下载 如果老兄有好的例子,请给我介绍一下
    谢谢!
    [email protected]
      

  5.   

    不会,但是我有一个想法。
    就对最后的字符串进行分析。
    如果,最后的字符串包含有'.PHP?'or '.aps?',or'.xml?','.dll?','.apsx?'等等就再进一步读取网页。可能有这样的API,WINDOWS MESSAGE。看看吧。
      

  6.   

    怎么都没有高手帮帮我搞定这个问题吗?
    FLASHGET是怎么搞的啊?
    我真他妈不想活了。
      

  7.   

    用NMHTTP如何该变其下载的文件存放路径,我现在只能先下下来,让后再移动!
      

  8.   

    你看看这个行不行,从网上找的:
    uses 
    URLMon, ShellApi;function DownloadFile(SourceFile, DestFile: string): Boolean;begintryResult := UrlDownloadToFile(nil, PChar(SourceFile), PChar(DestFile), 0, nil) = 0;exceptResult := False;end;end;procedure TForm1.Button1Click(Sender: TObject);const// URL LocationSourceFile = 'http://www.google.com/intl/de/images/home_title.gif';// Where to save the fileDestFile = 'c:image.gif';beginif DownloadFile(SourceFile, DestFile) thenbeginShowMessage('Download succesful!');// Show downloaded image in your browserShellExecute(Application.Handle, PChar('open'), PChar(DestFile),PChar(''), nil, SW_NORMAL)endelseShowMessage('Error while downloading ' + SourceFile)end;// Minimum availability: Internet Explorer 3.0// Minimum operating systems Windows NT 4.0, Windows 95******************************2.}usesWininet;function DownloadURL(const aUrl: string): Boolean;varhSession: HINTERNET;hService: HINTERNET;lpBuffer: array[0..1024 + 1] of Char;dwBytesRead: DWORD;beginResult := False;// hSession := InternetOpen( 'MyApp', INTERNET_OPEN_TYPE_DIRECT, nil, nil, 0);hSession := InternetOpen('MyApp', INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0);tryif Assigned(hSession) thenbeginhService := InternetOpenUrl(hSession, PChar(aUrl), nil, 0, 0, 0);if Assigned(hService) thentrywhile True dobegindwBytesRead := 1024;InternetReadFile(hService, @lpBuffer, 1024, dwBytesRead);if dwBytesRead = 0 then break;lpBuffer[dwBytesRead] := #0;Form1.Memo1.Lines.Add(lpBuffer);end;Result := True;finallyInternetCloseHandle(hService);end;end;finallyInternetCloseHandle(hSession);end;end;******************************在Delphi中如何从网络中提取一个文件到本地计算机中,如提取<BR> http://www.abcdefg.com/software/a.zip到本地指定的目录中?在窗体中添加1个TNMHTTP控件(在FastNet页)然后在随便那个Button什么的下面加入如下代码: NMHTTP1.InputFileMode := ture;NMHTTP1.Body := '本地文件名';NMHTTP1.Header := 'Head.txt';NMHTTP1.OutputFileMode := FALSE;NMHTTP1.ReportLevel := Status_Basic;NMHTTP1.Proxy := '代理服务器的IP地址';NMHTTP1.ProxyPort := '代理服务器的端口号';With NMHTTP1.HeaderInfo doBeginCookie := '';LocalMailAddress := '';LocalProgram := '';Referer := '';UserID := '用户名称';Password := '用户口令';End;NMHTTP1.Get(‘http://www.abcdefg.com/software/a.zip’);试试吧,Delphi的目录中有TNMHTTP控件的例子。NT4+,Win95+,IE3+,你可以用URL Moniker的功能。uses URLMon;...OleCheck(URLDownloadToFile(nil,'URL','Filename',0,nil));其中最后一个参数你还可以传入一个IBindStatusCallback的实现以跟踪下载进度或控制中止下载。简单的场合一句话就搞定了。
      

  9.   

    我现在就是这个样子。
    不过是:
    NMHTTP1.Get(‘http://www.abcdefg.com/software/a.zip’);而不是
    NMHTTP1.Get(‘http://www.abcdefg.com/software/donw.asp?id=1’);
    我要下载这个
      

  10.   

    UP!UP!UP!UP!UP!UP!UP!UP!UP!UP!UP!UP!UP!UP!
      

  11.   

    现在还有一点点问题了。http://expert.csdn.net/Expert/topic/2214/2214355.xml?temp=.5562708
    请看这里。
      

  12.   

    Uses
      winInet;
    function GetInetFile (const fileURL, FileName: String): boolean;
    const BufferSize = 1024;
    var
     hSession, hURL: HInternet;
     Buffer: array[1..BufferSize] of Byte;
     BufferLen: DWORD;
     f: File;
     sAppName: string;
    begin
    Result:=False;
    sAppName := ExtractFileName(Application.ExeName);
    hSession := InternetOpen(PChar(sAppName),
                   INTERNET_OPEN_TYPE_PRECONFIG,
                  nil, nil, 0);
    try
     hURL := InternetOpenURL(hSession,
               PChar(fileURL),
               nil,0,0,0);
     try
      AssignFile(f, FileName);
      Rewrite(f,1);
      repeat
       InternetReadFile(hURL, @Buffer,
                        SizeOf(Buffer), BufferLen);
       BlockWrite(f, Buffer, BufferLen)
      until BufferLen = 0;
      CloseFile(f);
      Result:=True;
     finally
      InternetCloseHandle(hURL)
     end
    finally
     InternetCloseHandle(hSession)
    end
    end;procedure TForm1.Button3Click(Sender: TObject);
    var FileOnNet, LocalFileName: string;
    begin
      FileOnNet:='http://www.xxx.com/downing.asp?id=39'; 
      LocalFileName:='File Downloaded From the Net.zip';
      if GetInetFile(FileOnNet,LocalFileName)=True then
         ShowMessage('Download successful')
      else
         ShowMessage('Error in file download')
    end;
    呵呵.再次调整一下.也把引用贴出来。
      

  13.   

    http://www.xxx.com/down.asp?downid=1  //ASP传参数的一种方法,网页接到参数后,要处理后才能得到下边的结果。如果直接是http://www.xxx.com/abc.exe  //直接指向下载文件了。http://218.56.11.178:8020/web/index.aspx  下载基地  //就是这样做的。
      

  14.   

    这种软件都运用了一种网络路径智能分析算法,如果不能直接下载,需要程序去根据一定的规则进行分析从新整理出类似于http://www.xxx.com/zz.exe的可载路径~~~~~  如果你不了解这种换算方法就是有源码也不会用~~~~~~~  
    去去其他一些专门提供下载(大多是电影网站)的论坛,那里经常介绍一些下载技巧,其中就有将http://www.xxx.com/downing.asp?id=39解读成为http://www.xxx.com/zz.exe的方法,你读了之后会有启发,最好写出自己的算法~~~~~~~