參考資訊:
http://www.winprog.org/tutorial/
http://winapi.freetechsecrets.com/win32/
https://github.com/gammasoft71/Examples_Win32
http://masm32.com/board/index.php?topic=3584.0
https://learn.microsoft.com/en-us/windows/win32/winmsg/window-styles
main.c
#define WIN32_LEAN_AND_MEAN #include <tchar.h> #include <iomanip> #include <iostream> #include <urlmon.h> #include <wininet.h> #include <windows.h> int main(int argc, char** argv) { const TCHAR path[] = _T("putty.exe"); const TCHAR url[] = _T("https://the.earth.li/~sgtatham/putty/latest/w32/putty.exe"); printf("downloading: %s\n", url); printf("to local file: %s\n", path); DeleteUrlCacheEntry(url); HRESULT hr = URLDownloadToFile(NULL, url, path, 0, NULL); printf("hr:0x%x\n", hr); return 0; }
編譯
$ i686-w64-mingw32-g++ -U __STRICT_ANSI__ -o url.exe main.c -lwininet -luuid -lurlmon -static