Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Microsoft: FoxPro FAQ


Add Download Ability to Your App in 2 Seconds by craigsboyd
Posted: 6 Jul 03 (Edited 18 Feb 05)

Slighthaze = NULL


I stumbled on the below method and couldn't believe how simple it was.  Download with progress indication and everything.  I have made some revisions since this FAQ was first posted, thanks to machele for asking all the right questions.
This program can handle username/password and unsafe characters in the URL.  An example of a fullblown URL for this program would be something like sURLandFile = "ftp://username:password@domain/Some Path/Some File I Want.zip" <-- note that the path and filename have spaces in them (space is an unsafe URL character that needs to be turned into escape sequences - see HandleUnsafeChars function below)

***(Cut-n-paste the code into a prg file and run from within VFP)***

Local sURLandFile, nRet

Declare DoFileDownload IN shdocvw.dll STRING lpszFile

sURLandFile = "ftp://ftp.microsoft.com/deskapps/readme.txt";

sURLandFile = HandleUnsafeChars(sURLandFile)

IF !EMPTY(sURLandFile)
    MESSAGEBOX("Function returned an empty length string.",16,"Something is Wrong")

FUNCTION HandleUnsafeChars(sAddressUrl)
***Purpose: Change unsafe chars to escape sequences
    #DEFINE ICU_BROWSER_MODE 33554432 && 0x2000000

    DECLARE INTEGER InternetCanonicalizeUrl IN wininet;

    LOCAL sNewUrl, nResult

    nResult = 250
    sNewUrl = Replicate(Chr(0), nResult)

    IF InternetCanonicalizeUrl (sAddressUrl,@sNewUrl, @nResult, ICU_BROWSER_MODE) <> 0
        RETURN Left(sNewUrl, nResult)
        RETURN ""
ENDFUNC &&HandleUnsafeChars

Back to Microsoft: FoxPro FAQ Index
Back to Microsoft: FoxPro Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close