[AccessD] capture an image from the web

jwcolby jwcolby at colbyconsulting.com
Wed Jun 22 06:08:53 CDT 2011


LOL, my life is one big senior moment anymore.  Actually what happens is that if I am not into 
something, I don't pay any attention to it.  This is the first project where I use this stuff so 
yea, this is the first time that I paid any attention.

I like your code because of the return codes.

Thanks Gustav.

John W. Colby
www.ColbyConsulting.com

On 6/22/2011 4:33 AM, Gustav Brock wrote:
> Hi John
>
> Chuckle! Having a senior moment again? Or just too busy?
>
> I think Jim DeMarco (still with us?) was the first to post code like that in July 2001, and since then about eight times similar code has been brought to you by Marty and Stuart to name a few.
> My own variation - which sports some error reporting for a more demanding use which I think you will like - has been posted thrice since 2004.
> Here goes again. And the example URLs are still live(!):
>
> <code>
> Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" ( _
>    ByVal pCaller As Long, _
>    ByVal szURL As String, _
>    ByVal szFileName As String, _
>    ByVal dwReserved As Long, _
>    ByVal lpfnCB As Long) _
>    As Long
>
> Public Function DownloadFile( _
>    ByVal strURL As String, _
>    ByVal strLocalFilename As String) _
>    As Long
>
> ' Download file or page with public access from the web.
> ' 2004-12-17. Cactus Data ApS, CPH.
>
> ' Usage, download a file:
> ' lngRet = DownloadFile("http://www.databaseadvisors.com/Graphics/conf2002/2002ConferencePicsbySmolin/images/dba02smolin27.jpg", "c:\happybassett.jpg")
> '
> ' Usage, download a page:
> ' lngRet = DownloadFile("http://www.databaseadvisors.com/conf2002/conf200202.asp", "c:\dbaconference.htm")
>
> ' Returns 0 if success, error code if not.
> ' Error codes:
> ' -2146697210 "file not found".
> ' -2146697211 "domain not found".
>
> ' Limitation.
> ' Does not check if local file was created successfully.
>
>    Dim lngRetVal As Long
>
>    lngRetVal = URLDownloadToFile(0, strURL&  vbNullChar, strLocalFilename&  vbNullChar, 0, 0)
>
>    DownloadFile = lngRetVal
>
> End Function
> </code>
>
> /gustav
>
>
>>>> jwcolby at colbyconsulting.com 21-06-2011 23:15>>>
> In my InmateCheckout application I use the Microsoft WebBrowser activeX object for looking up info
> about the inmates.  One of the things I do is to display a picture using a link as follows:
>
> http://webapps6.doc.state.nc.us/opi/viewpicture.do?method=view&showDate=N&pictureType=I&offenderID=
>
> and then I append the OpusID (inmate number) so I end up with something like:
>
> http://webapps6.doc.state.nc.us/opi/viewpicture.do?method=view&showDate=N&pictureType=I&offenderID=0002836
>
>
> So I wanted to download these pictures so that the user can step through the inmate records
> displaying their photo without having to go get the photo every single time.  Plus this allows me to
> print a report with photo for my own use.
>
> I found this on the internet:
>
> http://vbnet.mvps.org/index.html?code/internet/urldownloadtofile.htm
>
> Built in to windows and... it just works!
>
> Technology is wonderful when it works!
>



More information about the AccessD mailing list