Immediate close?

This is a discussion on Immediate close? within the C++ Programming forums, part of the General Programming Boards category; Hi, I have the following very simple program to download an image from the internet, and store it on my ...

  1. #1
    Registered User
    Join Date
    Feb 2010
    Posts
    128

    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
    612
    It does that already, the press a key thing is something Visual Studio adds when you select Start without Debugging

  3. #3
    Registered User
    Join Date
    Feb 2010
    Posts
    128
    I think I just solved it - convert to multi-threaded debug!

    Yes - thanks adeyblue!

  4. #4
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    22,985
    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-24-2008, 12:00 AM
  2. how do i close one window at a time?
    By stde in forum Windows Programming
    Replies: 4
    Last Post: 08-01-2006, 01:43 PM
  3. open() and close()
    By SoFarAway in forum C Programming
    Replies: 3
    Last Post: 04-08-2005, 02: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, 06:38 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21