HI , i need help with a c++ code that downloads a single file from a DIRECT link and save it somewhere on the computer i am working under windows and i have searched google but i didnt find anything simple just tons of codes that i cant understand i dont need any progress of the download or anything just simple file download , Thanks in advanced

search for the WinINet. for Http.

Actually, for simple file downloads you will need only URLDownloadToFile API.

HRESULT URLDownloadToFile(
LPUNKNOWN pCaller,
LPCTSTR szURL,
LPCTSTR szFileName,
DWORD dwReserved,
LPBINDSTATUSCALLBACK lpfnCB
);


Check it here:
http://msdn.microsoft.com/en-us/library/ms775123(VS.85).aspx

THANKS borned bored thats exactly what i was looking about

But please can you tell me how to use it is there any library to include
because i am new to api so i dont know how to use them in my application , Thanks in advanced

Try this: both first and last parameters can be NULL.

URLDownloadToFile(NULL, "www.DaniWeb.com/something.jpg",
     "c:\\mydir\\something.jpg", NULL);

This code is not sufficient and won't work on some Windows SPx.....

This code is not sufficient and won't work on some Windows SPx.....

This worked for me on Vista Home using VC++ 2008 Express. But yes, anyone wanting to use that function needs to know what they are doing, such as reading all about it on MSDN and possibly other places.

#include <windows.h>

int _tmain(int argc, _TCHAR* argv[])
{
URLDownloadToFile(NULL, _T("http://www.daniweb.com/certificates/posts46588.jpg"),
     _T("c:\\dvlp\\posts46588.jpg"), NULL, NULL);
	return 0;
}

This worked for me on Vista Home using VC++ 2008 Express. But yes, anyone wanting to use that function needs to know what they are doing, such as reading all about it on MSDN and possibly other places.

#include <windows.h>

int _tmain(int argc, _TCHAR* argv[])
{
URLDownloadToFile(NULL, _T("http://www.daniweb.com/certificates/posts46588.jpg"),
     _T("c:\\dvlp\\posts46588.jpg"), NULL, NULL);
	return 0;
}

It doesnt work for me i am working under windows 7 with Vc Express 2008 Which type of project did u create ?
Thnx for help

windows 7 is still in beta, it will probably work ok when released this October. I just created a standard console project.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.