TELECHARGER UN FICHIER (WIN32)

BruNews Messages postés 21040 Date d'inscription jeudi 23 janvier 2003 Statut Modérateur Dernière intervention 21 août 2019 - 30 juin 2005 à 21:48
elguevel Messages postés 718 Date d'inscription jeudi 19 décembre 2002 Statut Membre Dernière intervention 22 novembre 2016 - 3 oct. 2005 à 13:23
Cette discussion concerne un article du site. Pour la consulter dans son contexte d'origine, cliquez sur le lien ci-dessous.

https://codes-sources.commentcamarche.net/source/32450-telecharger-un-fichier-win32

elguevel Messages postés 718 Date d'inscription jeudi 19 décembre 2002 Statut Membre Dernière intervention 22 novembre 2016 3
3 oct. 2005 à 13:23
L'api Wininet n'aurai pas été plus simple (et puis pas besoin de dll externe ) ?
glipper Messages postés 246 Date d'inscription dimanche 2 juin 2002 Statut Membre Dernière intervention 11 septembre 2016 1
6 juil. 2005 à 10:23
Super ça marche très bien :)
Merci
cs_magma Messages postés 198 Date d'inscription vendredi 4 avril 2003 Statut Membre Dernière intervention 18 mars 2011
6 juil. 2005 à 08:16
Essaie de cette manière pour voir...



#include <windows.h>
#include "telec.h"

typedef ULONG (WINAPI *DFD)(LPCWSTR);

//-----------------------------------------------------------------------------
BOOL CALLBACK MainProc(HWND hDlg,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
char szAnsiURL[MAX_PATH];
WCHAR szWideURL[MAX_PATH];
static HINSTANCE hInstDLL;
static HBRUSH hbEdit;
DFD fpDFD;
//static FARPROC fpDFD;

switch (uMsg)
{
case WM_INITDIALOG:
hInstDLL = LoadLibrary("shdocvw.dll");
hbEdit = CreateSolidBrush(RGB(255, 255, 200));
SetFocus(GetDlgItem(hDlg, IDC_EDIT));
return FALSE;

case WM_CTLCOLOREDIT:
SetTextColor((HDC)wParam, RGB(255, 0, 0));
SetBkColor((HDC)wParam, RGB(255, 255, 200));
return (BOOL)hbEdit;

case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDC_CLIC:
GetDlgItemText(hDlg, IDC_EDIT, szAnsiURL, MAX_PATH);

if(hInstDLL)
{
if(fpDFD = (DFD)GetProcAddress(hInstDLL, "DoFileDownload"))
{
MultiByteToWideChar(CP_ACP, 0, szAnsiURL, -1, szWideURL, sizeof(szWideURL));
fpDFD(szWideURL);
}
else
MessageBox(hDlg, "Erreur: GetProcAddress() ", "Téléchargement", MB_OK|MB_ICONSTOP);
}
else
MessageBox(hDlg, "Erreur: LoadLibrary() ", "Téléchargement", MB_OK|MB_ICONSTOP);

SetFocus(GetDlgItem(hDlg, IDC_EDIT));
return TRUE;

case IDCANCEL:
FreeLibrary(hInstDLL);
EndDialog (hDlg, 0);
return TRUE;
}
break;
}
return FALSE;
}

//-----------------------------------------------------------------------------
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpLine, int nShow)
{
return DialogBox(hInst, (LPCSTR)IDD_MAIN, (HWND)NULL, (DLGPROC)MainProc);
}
glipper Messages postés 246 Date d'inscription dimanche 2 juin 2002 Statut Membre Dernière intervention 11 septembre 2016 1
5 juil. 2005 à 20:06
Moi je n'arrive pas à le compiler en fait.
J'utilise Visual C++ 5. En fait il refuse celle ligne :

(*fpDFD)(szWideURL);

error C2197: 'int(__stdcall *)(void)' : too many actual parameters

Glipper
cs_magma Messages postés 198 Date d'inscription vendredi 4 avril 2003 Statut Membre Dernière intervention 18 mars 2011
2 juil. 2005 à 12:52
J'ai constaté qu'il y avait des tonnes de sources
en VB utilisant l'API DoFileDownload (Voir Google).
Celle-ci est une adaptation en C.
Zazour Messages postés 120 Date d'inscription mercredi 7 mai 2003 Statut Membre Dernière intervention 14 janvier 2006
1 juil. 2005 à 17:29
tu peux expliquer le continu de la dll "shdocvw.dll" que tu utilises STP ?
cs_eRoZion Messages postés 241 Date d'inscription vendredi 23 mai 2003 Statut Membre Dernière intervention 8 octobre 2007 1
1 juil. 2005 à 05:25
Salut,
à prioris pas de problème chez moi, tout fonctionne.


eRoZion
cs_Joky Messages postés 1787 Date d'inscription lundi 22 novembre 2004 Statut Membre Dernière intervention 31 janvier 2009 2
30 juin 2005 à 22:43
J'ai la même erreur :)
Et vala aucune explication à donné. Mon compte est en mode administrateur, je passe par un routeur si ça peut aidé lol, et j'aime les frites, je sais pas si ça a de l'importance mais voila ;)
DeAtHCrAsH Messages postés 2670 Date d'inscription vendredi 25 janvier 2002 Statut Membre Dernière intervention 6 février 2013
30 juin 2005 à 22:16
Erreur : Les paramètres de sécurité actuels ne vous permettent pas de télécharger ce fichier.

Explications ?
BruNews Messages postés 21040 Date d'inscription jeudi 23 janvier 2003 Statut Modérateur Dernière intervention 21 août 2019
30 juin 2005 à 21:48
Crée 1 seule fois ton HBRUSH dans WM_INITDIALOG.
Rejoignez-nous