Thread: Closing the console

  1. #1
    Registered User
    Join Date
    Feb 2009
    Posts
    6

    Closing the console

    I use bloodshed dev-C++ compiler on vista and i made a program in C but i want to be able to stop the console window showing but i dont know how to do this. I want this program to constantly run in the backgroud without a window open for it. I dont know how to get rid of it. Is there some code or just an option i can turn off? If so i haven't seen it and yes I have googled a lot but found nothing.

  2. #2
    Code Abuser
    Join Date
    Jan 2009
    Posts
    16
    To my knowledge, the only way of accomplishing that is to use the Windows API to create a GUI-type application, but then you never create a window onscreen. There isn't a way to do it with standard C, since the console is just a low level way of interfacing with a program, and the only portable way possible, so if Windows determines that the application in question isn't a GUI-based program, it shows up the console by default.

  3. #3
    Registered User
    Join Date
    Feb 2009
    Posts
    6
    How would I do that then? I have built the program fine I just want to get rid of that box, and I dont need to create another window.

  4. #4
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    What you want is a Windows service install.

    That's a program that has no window.

    For a list of yours:

    Start >> Control Panel >> Administrative Tools >> Services.

    And yes, there are programs designed to install a program, as a service. I'll have to refer you to Microsoft, but search for Windows service, and iirc, one program was srvany.exe.

    There is another program that does about the same thing, but with a different way of handling the services it installs. Sorry, can't remember that name.


    You're working with the registry here, so be *very* careful, make a backup first of the registry, and I'd review things like "checkpoints" as well, and how to go about using them, if need be.

    Start >> run >> regedit, of course, is your registry editor.

  5. #5
    Code Abuser
    Join Date
    Jan 2009
    Posts
    16
    It's been a while since I wrote anything on a Windows machine, but if I recall correctly you should just be able to replace your main() function with the WinMain function and Windows will believe that you're running a GUI application. Yeah, you won't have a 'proper' return value since you aren't handling any kind of callbacks, but if you return 0 when you exit it should work.

  6. #6
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Not sure if it's any help, but Win2K onwards have FreeConsole which may do what you want.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Closing the Console w/ GLUT
    By Matt3000 in forum Game Programming
    Replies: 2
    Last Post: 08-04-2006, 07:07 PM
  2. Full Screen Console
    By St0rmTroop3er in forum C++ Programming
    Replies: 1
    Last Post: 09-26-2005, 09:59 PM
  3. Problems with a simple console game
    By DZeek in forum C++ Programming
    Replies: 9
    Last Post: 03-06-2005, 02:02 PM
  4. Console Functions Help
    By Artist_of_dream in forum C++ Programming
    Replies: 9
    Last Post: 12-04-2004, 03:44 AM
  5. Just one Question?
    By Irish-Slasher in forum C++ Programming
    Replies: 6
    Last Post: 02-12-2002, 10:19 AM