Thread: Immediate close?

  1. #1
    george7378
    Guest

    Immediate close?

    Hi,

    I have the following very simple program to download an image from the internet, and store it on my HD:

    Code:
    #include <iostream>
    #include <urlmon.h>
    #pragma comment(lib, "urlmon.lib")
    
    using namespace std;
    
    int main (){
    
    cout << "Downloading latest image..." << endl;
    
    HRESULT hr = URLDownloadToFile( NULL, L"http://sohowww.nascom.nasa.gov/data/realtime/hmi_igr/1024/latest.jpg", L"c://Documents and Settings//XP//My Documents//latestsun.bmp", 0, NULL );
    
    return 0;
    }
    However, I want this program to run, download the image, and then close immediately without displaying the 'Press any key to continue...' message. Is there a way to make a program close without the user pressing a key? It sounds simple I know, but I have been googling, and can't find anything!

    Thanks.

  2. #2
    'Allo, 'Allo, Allo
    Join Date
    Apr 2008
    Posts
    639
    It does that already, the press a key thing is something Visual Studio adds when you select Start without Debugging

  3. #3
    george7378
    Guest
    I think I just solved it - convert to multi-threaded debug!

    Yes - thanks adeyblue!

  4. #4
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Close an HTTPListenerResponse.OutputStreram
    By George2 in forum C# Programming
    Replies: 0
    Last Post: 04-23-2008, 11:00 PM
  2. how do i close one window at a time?
    By stde in forum Windows Programming
    Replies: 4
    Last Post: 08-01-2006, 12:43 PM
  3. open() and close()
    By SoFarAway in forum C Programming
    Replies: 3
    Last Post: 04-08-2005, 01:16 PM
  4. XWindows- Close window event?
    By Exile in forum Linux Programming
    Replies: 8
    Last Post: 01-09-2005, 10:39 PM
  5. Ghost in the CD Drive
    By Natase in forum A Brief History of Cprogramming.com
    Replies: 17
    Last Post: 10-12-2001, 05:38 PM