Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

visual c++ dowload images

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi I'd like to know how could I download an image from a web site? thank you
 
You could try it with this:
Creates a file and copies raw bytes from image to it

//////////////////////////////////////////////////
CFile myFile("image name.jpg", CFile::modeCreate | CFile::modeReadWrite);

CInternetSession session;
CStdioFile* file= session.OpenURL(URL /*CString to image URL*/, 1, INTERNET_FLAG_TRANSFER_BINARY)

UINT MaxImageSize= 1000000;
BYTE* buffer= new BYTE[MaxImageSize];
UINT size= file->Read(buffer, MaxImageSize);
if(size==0)
{
MessageBox("Cannot transfer image data to file");
}
myFile.Write(buffer, size);
delete [] buffer;
buffer= NULL;
///////////////////////////////////////////
Needs header <afxinet.h>
Worked at my programm (from Visual Studio.NET)
The biggest image possible im this example is 1000000 bytes big. Could also be bigger
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top