First, let's start with a few APIs.
_getcwd
Gets the current working directory.
Char *_getcwd ( char *buffer, int maxlen );
Buffer
Storage location for the path.
MaxLen
Maximum length of the path in Characters:char for _GETCWD and wchar_t for _WGETCWD.
Easy to know: buffer is the path
MaxLen: Is the length
function is to get the path of the current program
Next API
Urldownloadtofile function
Downloads bits from the Internet and saves them to a file.
Char *_getcwd ( char *buffer, int maxlen ); wchar_t *_wgetcwd ( wchar_t *buffer, int maxlen );
Here's the code:
#include <Windows.h> #include <stdio.h> #include <direct.h> #pragma comment (lib , "URlmon") int main () { char buffer[max_path]; _GETCWD (buffer, MAX_PATH); strcat_s (buffer, "//1.jpg"); HRESULT Result = Urldownloadtofilea (NULL, "HTTP://112.22.245.11:443/DOWN/DE0243D60205717A2A74AEA53C0C500C-46353/1". jpg?cts=yd-f-u13274580& ctp=111a23a228a125&ctt=1484747960&limit=1&spd=1300000&ctk= 4ab73a4a76e47ad0b181d0f9fc47b6a1&chk=de0243d60205717a2a74aea53c0c500c-46353 ", buffer, 0, NULL); Switch (Result) {case s_ok:printf ("The download started successfully.\n"); Case e_outofmemory:printf ("The buffer length is invalid, or there are insufficient memory to complete the operation.\n"); break; } return 0; }
Program run:
The above is the easy implementation of the content of the file download, more relevant content please pay attention to topic.alibabacloud.com (www.php.cn)!