Hiding the program

This is a discussion on Hiding the program within the C++ Programming forums, part of the General Programming Boards category; I need to write an invisible program that does nothing I can use FreeConsole() to hide the program, but how ...

  1. #1
    Registered User
    Join Date
    Mar 2008
    Posts
    6

    Hiding the program

    I need to write an invisible program that does nothing

    I can use FreeConsole() to hide the program, but how do I pause it after that? Simple things like system(pause) and getchar() dont work when you detach it from the console.

    I don't want it to do anything, but I want it to be running (and not using any CPU cycles)

    I understand that the only way to close it will be with task manager, thats fine

    Code can be C or C++

    EDIT: I know it sounds like I'm asking you to write the program for me, but I can't imagine it'll be much more than 5 lines long. I'm sure there is a simple command I'm missing
    Last edited by napalm; 08-27-2008 at 04:52 PM.

  2. #2
    The larch
    Join Date
    May 2006
    Posts
    3,573
    I need to write an invisible program that does nothing
    You don't have to do anything. Just pretend you have it.
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  3. #3
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    If you just want to wait forever, you can either do
    Code:
    #include <windows.h>
    ....
    while(1)
       Sleep(10000);
    or
    Code:
    #include <windows.h>
    
    HANDLE h = GetCurrentThread();
    
    WaitForSingleObject(h, INFINITE);
    // That will wait for the current thread to terminate - since it's the CURRENT one, it will NEVER terminate. Just wait and wait.
    Obviously, waiting for any other activity that doesn't happen will work - but current thread is never going to be finished.

    --
    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.

  4. #4
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    I guess I will be the obligatory jerk who gets into symantics. By invisible do you mean it doesn't show up when you open the process manager? Or do you simply mean a program that occupies resources yet doesn't have a window.

    For the specific task you are describing, my years of programming experience and decades of computer usage tells me that anon's solution is probably the best. Its multi-platform, its fast, it doesn't bog down the system unless the system is already bogged down. It never corrupts data or locks another thread from running. The best part is that it won't use any CPU cycles. All alternatives will occupy memory and take ticks off a CPU (even if they are few and far between). Plus you have to do some trickery in order to make a process not show up on the process manager.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Issue with program that's calling a function and has a loop
    By tigerfansince84 in forum C++ Programming
    Replies: 9
    Last Post: 11-12-2008, 01:38 PM
  2. Need help with a program, theres something in it for you
    By engstudent363 in forum C Programming
    Replies: 1
    Last Post: 02-29-2008, 01:41 PM
  3. Replies: 4
    Last Post: 02-21-2008, 10:39 AM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 11:04 PM

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