Download a file using a dll.

urlmon.dll

See version :

Pas de dépendances

Download :

#include <windows.h>
#include <tchar.h>
#include <stdio.h>

#define URL _T("http://fvirtman.free.fr/index.html") // Url du fichier distant a recuperer
#define LOC _T("c:\\plouf.html") // Nom du fichier local qui sera cree

// Type pointeur sur fonction 'URLDownloadToFile()'
typedef HRESULT (WINAPI *DF)(LPVOID,LPCTSTR,LPCTSTR,DWORD,LPVOID);

int main(void)
{
    DF df;
    HMODULE hUrl;
    if(!(hUrl = LoadLibrary(_T("urlmon.dll"))))
    {
        printf("\nEchec LoadLibrary() !\n");
        return 1;
    }
#ifdef UNICODE
    if(!(df = (DF)GetProcAddress(hUrl, "URLDownloadToFileW")))
#else
    if(!(df = (DF)GetProcAddress(hUrl, "URLDownloadToFileA")))
#endif
    {
        printf("\nEchec GetProcAddress() !\n");  
        FreeLibrary(hUrl);
        return 2;
    }
    printf("\nTelechargement de %s ...", URL);
    if(df(0, URL, LOC, 0, 0))
    {
        printf("\nEchec URLDownloadToFile() !\n");  
        FreeLibrary(hUrl);
        return 3;
    }
    _tprintf(_T("\nLe fichier a ete copie ici: %s\n"), LOC);      
    FreeLibrary(hUrl);  
    return 0;
}




Explanations

	No explanations yet.