Thread: Immediate close?

  1. #1
    Registered User
    Join Date
    Feb 2010

    Immediate close?


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

    #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"", 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!


  2. #2
    'Allo, 'Allo, Allo
    Join Date
    Apr 2008
    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
    I think I just solved it - convert to multi-threaded debug!

    Yes - thanks adeyblue!

  4. #4
    Join Date
    Oct 2007
    Inside my computer
    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
    Replies: 17
    Last Post: 10-12-2001, 05:38 PM