473,406 Members | 2,312 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Retrieval Of Files From The Internet

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,"URLDownloadToFile A");
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

Jul 11 '07 #1
1 1643
On Jul 11, 3:18 pm, alphaLa...@gmail.com wrote:
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,"URLDownloadToFile A");
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
Hi Laura, in your first example, I think you should use lower case in
urlmon.dll, also I don't think you need #include "stdafx.h" and
#include <urlmon.h(unless they're for something else in the program
you're writing).

Jul 22 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Lyle H. Gray | last post by:
We load a table from a text file using Data Transformation Services. The source file is already sorted by primary key order. After the DTS load, the default retrieval order on the target table...
1
by: phpninja | last post by:
Greetings, I was wondering if it is possible to delete someone's temporary internet files with javascript? Basically I'm am using a PDF module called HTML_ToPDF. The pdf module takes some output...
4
by: Nicolás Castagnet | last post by:
Hi, I write this post because I notice a strange behavior related with "Temporary Internet Files" and maybe some of you can help me to understand it. I am working in a web application with...
2
by: addicted2rpg | last post by:
For background on this problem, see: http://support.microsoft.com/kb/q249232/ I essentially get a IHTMLWindow2 object, IHTMLDocument2 object, etc.. from an HWND of an internet explorer process. ...
2
by: hari0007 | last post by:
I need some help in completing my college project I searched all throught the internet but I couldnt find the solution which can help me out. My project requires implementation of fuzzy set...
12
by: grace | last post by:
i am wondering why my database retrieval becomes too slow...we set up a new server (ubuntu, breezy badger) machine where we transferred all our files from the old server.. Our new server uses Asus...
0
by: JosAH | last post by:
Greetings, Introduction At the end of the last Compiler article part I stated that I wanted to write about text processing. I had no idea what exactly to talk about; until my wife commanded...
0
by: JosAH | last post by:
Greetings, welcome back; above we discussed the peripherals of the Library class: loading and saving such an instantiation of it, the BookMark interface and then some. This part of the article...
0
by: Hul Tytus | last post by:
comp.infosystems.www.authoring.html file retrieval services on the web? Do file retrieval services exist on the internet that allow a web site at www.this.com to have html code as below? Keeping...
0
by: Hul Tytus | last post by:
comp.infosystems.www.authoring.html file retrieval services on the web Do file retrieval services exist on the internet that allow a web site at www.this.com to have html code as below? Keeping...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.