DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Method to report if a process exits.

  1. #1
    Join Date
    Apr 2006
    Posts
    64

    Method to report if a process exits.

    hey guys,
    help me out please,
    My program calls a windows program say windows media player.
    I start it and give the process a name so i know the name of
    process and can stop it any time. But.. I want that when user
    exits the windows media player, should the next statement of program run.
    I tried using ->hasExited method and made the whole program sleep as windows media player once running is independent of it , only when it exit
    should the program wake up again. But if I make it sleep it crashes and does not respond. Is there any thing like do nothing and wait. I have also
    tried ->Responding but still not much output.
    I ll try to register my program thread and then make it sleep but do not know it will work or not. Anybody has a better idea.
    The problem looks very simple but the solution is tricky.
    Please help me out.
    cheers,
    nadz

  2. #2
    Join Date
    Jan 2005
    Location
    UK
    Posts
    604
    Hi,

    have a look at MSDN. Search for:
    Enumerating All Modules For a Process, Process Status Helper and EnumProcesses. That should give you the information you need. You might need to download the platform SDK from the microsoft site (I think download.microsoft.com)

    Cheers,

    D
    DKyb
    -------------------------------
    Life is a short warm moment -
    Death is the long cold rest.
    Pink Floyd
    -------------------------------

  3. #3
    Join Date
    May 2006
    Posts
    176
    I think you should start the program using CreateProcess function. In this case you will obtains the handle of the launched process, which can be later used in a wait function.

    You can try this:

    Code:
    PROCESS_INFORMATION pi;
    STARTUPINFO si = { sizeof(STARTUP_INFO) };
    CreateProcess( "WMPlayer.exe", NULL, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
    Now you have the handle of the started process in pi structure. In order to wait for termination, execute this:

    Code:
    WaitForSingleObject(pi.hProcess, INFINITE);
    Hope it helps.

  4. #4
    Join Date
    Apr 2006
    Posts
    64
    Thanks for reply.
    I think i m using the equivalent in .net, I have got into another problem now.
    I need help for ping command. I need to save the results of ping command.
    I am starting a new thread too for it.
    Thanks

Similar Threads

  1. Replies: 2
    Last Post: 01-27-2007, 07:28 AM
  2. Comparing .NET delegates
    By Quimbly in forum .NET
    Replies: 1
    Last Post: 04-21-2006, 11:51 AM
  3. Replies: 1
    Last Post: 04-13-2006, 04:57 AM
  4. HowTo - Min And Max A Form By Process!
    By Jugg in forum VB Classic
    Replies: 3
    Last Post: 04-03-2006, 12:40 AM
  5. Replies: 5
    Last Post: 07-07-2000, 02:04 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center