惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

SecWiki News
SecWiki News
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
Visual Studio Blog
博客园 - 叶小钗
S
SegmentFault 最新的问题
IT之家
IT之家
大猫的无限游戏
大猫的无限游戏
博客园_首页
Apple Machine Learning Research
Apple Machine Learning Research
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
月光博客
月光博客
酷 壳 – CoolShell
酷 壳 – CoolShell
腾讯CDC
D
Darknet – Hacking Tools, Hacker News & Cyber Security
V
V2EX
阮一峰的网络日志
阮一峰的网络日志
L
Lohrmann on Cybersecurity
量子位
C
Cyber Attacks, Cyber Crime and Cyber Security
T
Tor Project blog
J
Java Code Geeks
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
博客园 - 三生石上(FineUI控件)
Attack and Defense Labs
Attack and Defense Labs
AI
AI
The Cloudflare Blog
T
Tailwind CSS Blog
S
Schneier on Security
爱范儿
爱范儿
PCI Perspectives
PCI Perspectives
Stack Overflow Blog
Stack Overflow Blog
S
Secure Thoughts
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
T
The Exploit Database - CXSecurity.com
博客园 - 【当耐特】
V2EX - 技术
V2EX - 技术
S
Securelist
P
Proofpoint News Feed
T
Threat Research - Cisco Blogs
Help Net Security
Help Net Security
C
Cisco Blogs
N
News and Events Feed by Topic
人人都是产品经理
人人都是产品经理
B
Blog RSS Feed
K
Kaspersky official blog
T
The Blog of Author Tim Ferriss
G
Google Developers Blog
S
Security Affairs
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Simon Willison's Weblog
Simon Willison's Weblog

博客园 - 浪地

删除excel中重复的数据 - 浪地 - 博客园 SQL SERVER 与ACCESS、EXCEL的数据转换 水晶报表注册码 Request.ServerVariables的参数解析 - 浪地 - 博客园 Javascript中的函数替代ASP.NET的Server.UrlEncode C#实现的18位身份证格式验证算法(转) - 浪地 - 博客园 从SQL Server数据库提取图片并显示在DataGrid - 浪地 - 博客园 ASP.NET热点问题解答14个 把图片保存到sql server数据库里 JavaScript使用技巧精萃 - 浪地 - 博客园 T-SQL游标使用 SQL中通配符、转义符与"["号的使用 两台SQL Server数据同步解决方案 SQL Server中各个系统表的作用 SQL连接查询 SQL Server实用经验与技巧大汇集 SQLServer基本函数 ASP.NET中17种正则表达式(转) C#打包SQL数据库部署安装(原创啊)
从 HTTP 上下载文件示例
浪地 · 2006-12-29 · via 博客园 - 浪地

*直接运行下面 代码就可以了,在.vfp8.0环境下测试成功!


* How to download data of this reference (DBF files) using HTTP
* 从 HTTP 上下载文件
*------------------------------------------------------------------
Clea
#Define INTERNET_OPEN_TYPE_DIRECT    1
#Define INTERNET_FLAG_NEED_FILE     16

#Define HTTP_QUERY_CONTENT_TYPE     1
#Define HTTP_QUERY_CONTENT_LENGTH    5

Do Decl        && declare external functions
*If InternetCheckConnection("http://www.163.com/", 1, 0) <> 0 &&已经连接Internet
*Endif
* initialize Wininet library

Private hOpen
hOpen = InternetOpen ("vfp", INTERNET_OPEN_TYPE_DIRECT, 0, 0, 0)
If hOpen = 0
? "GetLastError:", GetLastError()
? "在本机上 WinInet 函数库无效"
Return
Endif

Local lcBaseUrl, lcDstPath, hFile, lcFile
lcBaseUrl = "http://ftpgz13.pconline.com.cn/pub/download/200203/Mp3RenameEasy.zip"&&根据实际修改这里的字符串
lcFile    = "Mp3RenameEasy.zip"&&保存的文件名
lcDstPath = "C:\" &&保存的路径

* get a handle of the remote file
hFile = InternetOpenUrl (hOpen,;
lcBaseUrl , "", 0,;
INTERNET_FLAG_NEED_FILE, 0)

If hFile <> 0
?hfile
* even if there is no such file, the most evidently
* you will get an ASCII file in response (404 error page)
= http2local (hFile, lcDstPath + lcFile)
= InternetCloseHandle (hFile)
Else
? "网址不能打开"
? "错误号:", GetLastError()
Endif

* release WinInet library
= InternetCloseHandle (hOpen)
Return        && main

*--------------------------------------------
Function http2local (hSource, lcTarget)
* reads data from a remote file
#Define TransferBuffer   4096
? lcTarget + " "

* create the target file

hTarget = Fcreate (lcTarget)
If (hTarget = -1)
  ?? "指定的目标文件无效"
  Return -1
Endif

Local Buffer , BufLen , dwIndex
Buffer = Space(128)
BufLen = Len(Buffer)
dwIndex = 0
If HttpQueryInfo(hSource, HTTP_QUERY_CONTENT_LENGTH, @Buffer, @BufLen, @dwIndex) = 0
  ?"获取文件信息失败!"
  Return -1
Endif
?
?"文件大小: " + Left(Buffer,buflen)+" / "

lnTotalBytesRead = 0
lnSec = Seconds()


Do While .T.
  If Inkey() = 27 && 按 "Esc" 键
   Exit
  Endif
  lcBuffer = Replicate(Chr(0), TransferBuffer)
  lnBytesRead = 0

  If InternetReadFile (hSource, @lcBuffer,TransferBuffer, @lnBytesRead) = 1

   = Fwrite (hTarget, lcBuffer, lnBytesRead)
   If lnBytesRead = 0
    Exit
   Endif
   lnTotalBytesRead = lnTotalBytesRead + lnBytesRead
   Wait Window Transform(Val(Buffer)/1024) + " KB / " + Transform(lnTotalBytesRead/1024) + " KB " Nowait

  Else
   Exit
  Endif
  DoEvents
Enddo

= Fclose (hTarget)
?? " " + Transform(lnTotalBytesRead) + " Bytes 完成  用时: " + Transform(Seconds() - lnSec) + " 秒"
Return  lnBytesRead
Endfunc

Procedure  Decl
Declare Integer InternetCheckConnection In wininet.Dll ;
  String lpszUrl ,;
  Integer dwFlags ,;
  Integer dwReserved

Declare Integer GetLastError In kernel32

Declare Integer InternetOpen In wininet;
  STRING  sAgent,;
  INTEGER lAccessTypem,;
  STRING  sProxyName,;
  STRING  sProxyBypass,;
  STRING  lFlags

Declare Integer InternetCloseHandle In wininet Integer hInet

Declare Integer InternetOpenUrl In wininet;
  INTEGER hInternet,;
  STRING  lpszUrl,;
  STRING  lpszHeaders,;
  INTEGER dwHeadersLength,;
  INTEGER dwFlags,;
  INTEGER dwContext

Declare Integer InternetReadFile In wininet;
  INTEGER   hFile,;
  STRING  @ lpBuffer,;
  INTEGER   dwNumberOfBytesToRead,;
  INTEGER @ lpdwNumberOfBytesRead

Declare Integer HttpQueryInfo In wininet ;
  INTEGER   hHttpRequest, ;
  INTEGER   lInfoLe