A
alphaLaura
Hi all,
I recently posted this topic on the Microsoft VC group, but I still
can't get my program working fluidly. As part of my work experience, I
need to write a program which downloads the content of a webpage and
saves it into some file on my computer. I have a program which -does-
work despite giving errors at runtime. Looks like this -
++++++++++++++++++++++++++++++++++++++++++++++++++
#include "stdafx.h"
#include <Urlmon.h>
#include <windows.h>
// fetchMET.cpp : Defines the entry point for the console application.
//
typedef void (*Funk)(LPVOID,char*,char*,int,int);
bool Download(char* URL, char* File_Name)
{
HINSTANCE Dll_Handle = LoadLibrary(_T("Urlmon.dll"));
if (Dll_Handle == NULL) return FALSE;
Funk DnLd = (Funk)GetProcAddress(Dll_Handle,"URLDownloadToFileA");
if (DnLd == NULL) return FALSE;
DnLd(0,URL,File_Name,0,0);
FreeLibrary(Dll_Handle);
return TRUE;
}
int main(int argc, char *argv[])
{
Download("http://weather.uwyo.edu/cgi-bin/sounding?
region=europe&TYPE=TEXT
%3ALIST&YEAR=2007&MONTH=07&FROM=1100&TO=1112&STNM=03953", "wx.txt");
return 0;
}
++++++++++++++++++++++++++++++++++++++++++++++++++
I originally wanted to used the URLDownloadToFile() function but that
also gave me numerous problems. The program for that was very basic
and looked like...
++++++++++++++++++++++++++++++++++++++++++++++++++
#include "stdafx.h"
#include <iostream>
#include <Urlmon.lib>
#include <Urlmon.h>
int main()
{
long int returnValue = 0;
LPCTSTR URL = _T("ftp://tgftp.nws.noaa.gov/data/observations/metar/
stations/EICK.TXT");
LPCTSTR FILENAME = _T("c:\\wx.txt");
returnValue = URLDownloadToFile(NULL, URL, FILENAME, 0, NULL);
return 0;
}
++++++++++++++++++++++++++++++++++++++++++++++++++
I'm just wondering if anybody who has worked on the same problem has
any advice or solutions? Both methods are not working so, any help
would be wonderful!
Laura
I recently posted this topic on the Microsoft VC group, but I still
can't get my program working fluidly. As part of my work experience, I
need to write a program which downloads the content of a webpage and
saves it into some file on my computer. I have a program which -does-
work despite giving errors at runtime. Looks like this -
++++++++++++++++++++++++++++++++++++++++++++++++++
#include "stdafx.h"
#include <Urlmon.h>
#include <windows.h>
// fetchMET.cpp : Defines the entry point for the console application.
//
typedef void (*Funk)(LPVOID,char*,char*,int,int);
bool Download(char* URL, char* File_Name)
{
HINSTANCE Dll_Handle = LoadLibrary(_T("Urlmon.dll"));
if (Dll_Handle == NULL) return FALSE;
Funk DnLd = (Funk)GetProcAddress(Dll_Handle,"URLDownloadToFileA");
if (DnLd == NULL) return FALSE;
DnLd(0,URL,File_Name,0,0);
FreeLibrary(Dll_Handle);
return TRUE;
}
int main(int argc, char *argv[])
{
Download("http://weather.uwyo.edu/cgi-bin/sounding?
region=europe&TYPE=TEXT
%3ALIST&YEAR=2007&MONTH=07&FROM=1100&TO=1112&STNM=03953", "wx.txt");
return 0;
}
++++++++++++++++++++++++++++++++++++++++++++++++++
I originally wanted to used the URLDownloadToFile() function but that
also gave me numerous problems. The program for that was very basic
and looked like...
++++++++++++++++++++++++++++++++++++++++++++++++++
#include "stdafx.h"
#include <iostream>
#include <Urlmon.lib>
#include <Urlmon.h>
int main()
{
long int returnValue = 0;
LPCTSTR URL = _T("ftp://tgftp.nws.noaa.gov/data/observations/metar/
stations/EICK.TXT");
LPCTSTR FILENAME = _T("c:\\wx.txt");
returnValue = URLDownloadToFile(NULL, URL, FILENAME, 0, NULL);
return 0;
}
++++++++++++++++++++++++++++++++++++++++++++++++++
I'm just wondering if anybody who has worked on the same problem has
any advice or solutions? Both methods are not working so, any help
would be wonderful!
Laura