Thread: How to hide command prompt using C language?

  1. #1
    Registered User
    Join Date
    Mar 2009
    Posts
    4

    How to hide command prompt using C language?

    Hi all,
    I am a newbie in C.
    I want to ask how to hide command prompt window while the process still running?
    I want to do this in C programming

    What i have done now is calling another program using this code
    (void)System("anotherprogram.exe");

    However, command prompt window still appear.

    Anyone know how to hide the command prompt window?

    Thanks alot guys

    Regards,

    deob

  2. #2
    Registered User
    Join Date
    Mar 2009
    Posts
    4
    anyone can help me?

    thxz

  3. #3
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    Quote Originally Posted by deob View Post
    anyone can help me?

    thxz
    read about CreateProcess
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  4. #4
    Registered User
    Join Date
    Mar 2009
    Posts
    4
    I have read and learned about create process.
    But I still dont understand how to use the function?
    Could anyone give me an example?

  5. #5
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    http://tinyurl.com/coqcza

    edit: It's going to require use of Windows libraries, since that's not the kind of thing covered by standard C. You'll probably want to start lower than this if you have a lot of trouble understanding the examples.

  6. #6
    Registered User
    Join Date
    Mar 2009
    Posts
    4
    I have made createprocess() method and called anotherprogram.exe
    However, the command prompt window still appear

    As i know, createprocess method is used to run a new program. It creates a new process and its primary thread. Nevertheless, it does not hide the command prompt.

    Anyone could explain me and help me to find the solution?

    Anyhelp is kindly welcomed

    Thx

    deob

  7. #7
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    Well once you've forked the new process you'd end the current process, and that should exit the command window. This is of course assuming that the command window only appeared in the first place because you ran a console program. If you invoked the program from the command-line when it was already open, I don't believe the OS is going to let you close it programmatically.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Why C Matters
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 136
    Last Post: 01-16-2008, 09:09 AM
  2. What language did they make Java in?
    By jverkoey in forum A Brief History of Cprogramming.com
    Replies: 17
    Last Post: 07-03-2005, 04:18 PM
  3. Strange loop
    By D@rk_force in forum C++ Programming
    Replies: 22
    Last Post: 12-18-2004, 02:40 PM
  4. Language of choice after C++
    By gandalf_bar in forum A Brief History of Cprogramming.com
    Replies: 47
    Last Post: 06-15-2004, 01:20 AM
  5. Language Script..
    By vasanth in forum A Brief History of Cprogramming.com
    Replies: 12
    Last Post: 03-30-2003, 06:48 AM