Run a program in the background

This is a discussion on Run a program in the background within the C Programming forums, part of the General Programming Boards category; Hi guys, I'm calling for a little help again I'm currently planning to make a little application to monitor a ...

  1. #1
    1ST » R. vd Kooij
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    154

    Run a program in the background

    Hi guys, I'm calling for a little help again

    I'm currently planning to make a little application to monitor a certain (public) directory on our company server to check for new internal orders (semicolon separated text files generated by another app I've made).

    What I'd like to do is create an application that's running in the background of Windows and only becomes active, or pops up once there's a new order.
    Therefore I was thinking of either:
    1) Make an application that runs as a Windows process and only let it appear if a new order is placed
    2) Minimize the application to the system tray and only let it appear if a new order is placed

    My questions are:
    1) Are the two options above even possible to make in C?
    2) If so, how?
    3) Or... Is there a better option than the two above?


    Thanks a lot in advance!

    René
    http://www.f1rstracing.nl/
    OS: Windows XP
    Compiler: Dev-C++

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    Quote Originally Posted by rkooij View Post
    1) Are the two options above even possible to make in C?
    Yes.

    Quote Originally Posted by rkooij View Post
    2) If so, how?
    1. Program starts.
    2. Program checks for files.
    3. While program finds files for dealing with, it stays open and alerts you, or whatever you want it to do.
    4. Program minimizes itself to systray.
    5. Program runs a function that alternates between Sleep()ing and checking directory.
    6. If file is found, goto step 3.


    Quote Originally Posted by rkooij View Post
    3) Or... Is there a better option than the two above?
    I don't know exactly what type of processing you wish to perform on the files that are being generated, so I can't help you there. It sounds like you want a program for you or some user to control that is active only when needed and inactive otherwise. If so, this is fine. If you want the program to run all the time in the background without ever appearing, and you want it running all the time, then you should consider running it as a Windows service.

    In terms of efficiency, you might be able to install some Windows hook to tell if the directory is being altered, instead of having your program constantly check the directory. I don't remember all the Windows system hooks that may apply to this.

  3. #3
    1ST » R. vd Kooij
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    154
    Quote Originally Posted by MacGyver View Post
    1. Program starts.
    2. Program checks for files.
    3. While program finds files for dealing with, it stays open and alerts you, or whatever you want it to do.
    4. Program minimizes itself to systray.
    5. Program runs a function that alternates between Sleep()ing and checking directory.
    6. If file is found, goto step 3.
    Thanks for your answer! ^ That's exactly what I had in mind yeah
    My question is about step 4... I can't find anywhere how I can make the program to minimize to the system tray... Could someone please give me a hint in the right direction?

    Thanks again,

    René
    http://www.f1rstracing.nl/
    OS: Windows XP
    Compiler: Dev-C++

  4. #4
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459

  5. #5
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    University of Waterloo
    Posts
    1,903
    You might also be interested in directory monitoring for Windows.

  6. #6
    1ST » R. vd Kooij
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    154
    Thanks for the answers guys, much appreciated. I see this needs some investigation, I'll report back if there's any problems/solutions

    René
    http://www.f1rstracing.nl/
    OS: Windows XP
    Compiler: Dev-C++

  7. #7
    1ST » R. vd Kooij
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    154
    In the end I found an easier and nicer solution in C# so I've decided to go with that
    http://www.f1rstracing.nl/
    OS: Windows XP
    Compiler: Dev-C++

  8. #8
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    Traitor. lol....

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. can't get this program to run correctly
    By Amyaayaa in forum C++ Programming
    Replies: 3
    Last Post: 02-05-2008, 03:16 PM
  2. Help me with my basic program, nothing I create will run
    By Ravens'sWrath in forum C Programming
    Replies: 31
    Last Post: 05-13-2007, 02:35 AM
  3. Replies: 2
    Last Post: 12-22-2006, 07:45 PM
  4. forcing a program to run in the background?
    By Geo-Fry in forum Tech Board
    Replies: 4
    Last Post: 10-27-2003, 07:11 PM

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