Welcome to Dream.In.Code
Become a C++ Expert!

Join 149,537 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,534 people online right now. Registration is fast and FREE... Join Now!




check and verify if a program is running or not

 
Reply to this topicStart new topic

check and verify if a program is running or not

Rating  5
doubts
26 Nov, 2007 - 04:23 AM
Post #1

New D.I.C Head
*

Joined: 1 Nov, 2007
Posts: 17


My Contributions
hi all...i am given this assignment....please help me out in this..

suppose i have an input text file in which i have name of some computer application like notepad, Internet Explorer etc..also a specified time for which that particular aaplcation can run in a day is given alongside the name of the application. Now i need to check if any of the program in the input text file is running or not. I also have an output file. If the particular application is running then i will check whether it's name is written in the output file or not. iI will repeat this check process after every 10 seconds. If the program is running then i will add 10 to the time of that application in output file. I will repeat this procedure till both the times in input and output files get matched. After they get matched, i will kill the process for that day. But after the date gets change, the application will reset to zero and the same procedure gets repeated.

please give me the idea for coding what to do and how to do in this problem...This is related to my job and i need to provide the answer by tomoorow's morning...

I know i've not provided any coding and this is against the rule but i really need help..please just give me some hint as to how the coding is to be done...
Thank you
User is offlineProfile CardPM
+Quote Post

doubts
RE: Check And Verify If A Program Is Running Or Not
26 Nov, 2007 - 07:41 PM
Post #2

New D.I.C Head
*

Joined: 1 Nov, 2007
Posts: 17


My Contributions
somebody atleast try n help me...please...
User is offlineProfile CardPM
+Quote Post

girasquid
RE: Check And Verify If A Program Is Running Or Not
26 Nov, 2007 - 08:53 PM
Post #3

Barbarbar
Group Icon

Joined: 3 Oct, 2006
Posts: 1,294



Thanked: 18 times
Dream Kudos: 725
My Contributions
Well, you might first want to create your project, and look into some code for reading and writing to files.
User is offlineProfile CardPM
+Quote Post

doubts
RE: Check And Verify If A Program Is Running Or Not
26 Nov, 2007 - 10:06 PM
Post #4

New D.I.C Head
*

Joined: 1 Nov, 2007
Posts: 17


My Contributions
Till now i've used the following coding which opens the program selected and showing the current time

CODE
// AssiDlg.h : header file
//

#if !defined(AFX_ASSIDLG_H__96E70519_BAA6_4851_8A14_CC1C27E3670C__INCLUDED_)
#define AFX_ASSIDLG_H__96E70519_BAA6_4851_8A14_CC1C27E3670C__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

/////////////////////////////////////////////////////////////////////////////
// CAssiDlg dialog

class CAssiDlg : public CDialog
{
// Construction
public:
    CAssiDlg(CWnd* pParent = NULL);    // standard constructor

// Dialog Data
    //{{AFX_DATA(CAssiDlg)
    enum { IDD = IDD_ASSI_DIALOG };
    CString    m_strProgToRun;
    BOOL    m_bEnablePgm;
    CString    m_sTime;
    CString    m_sCount;
    //}}AFX_DATA

    // ClassWizard generated virtual function overrides
    //{{AFX_VIRTUAL(CAssiDlg)
    protected:
    virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
    //}}AFX_VIRTUAL

// Implementation
protected:
    HICON m_hIcon;

    // Generated message map functions
    //{{AFX_MSG(CAssiDlg)
    virtual BOOL OnInitDialog();
    afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
    afx_msg void OnPaint();
    afx_msg HCURSOR OnQueryDragIcon();
    afx_msg void OnTrack();
    afx_msg void OnExit();
    afx_msg void OnEditchangeProgtorun();
    afx_msg void OnStaticpgm();
    afx_msg void OnTimer(UINT nIDEvent);
    //}}AFX_MSG
    DECLARE_MESSAGE_MAP()
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_ASSIDLG_H__96E70519_BAA6_4851_8A14_CC1C27E3670C__INCLUDED_)

User is offlineProfile CardPM
+Quote Post

doubts
RE: Check And Verify If A Program Is Running Or Not
27 Nov, 2007 - 02:29 AM
Post #5

New D.I.C Head
*

Joined: 1 Nov, 2007
Posts: 17


My Contributions
Somebody please try and help me in this.... I am stuck in this coding since morning....Thanks
User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: Check And Verify If A Program Is Running Or Not
27 Nov, 2007 - 05:35 AM
Post #6

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 9,481



Thanked: 161 times
Dream Kudos: 9050
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
Are you using VB6 or VB.Net, which also includes Visual Basic 2003, Visual Basic 2005, Visual Basic 2005 Express Edition, etc.?
User is online!Profile CardPM
+Quote Post

doubts
RE: Check And Verify If A Program Is Running Or Not
28 Nov, 2007 - 08:38 PM
Post #7

New D.I.C Head
*

Joined: 1 Nov, 2007
Posts: 17


My Contributions
I am using VC++... i have done the coding for how to run a window... Also how to use the timer and increment count after every 10seconds... But now i need to connect the two of them... I need to increment the count after every 10seconds only if the application that i opened earlier is still open.
Please do help me in this..Thankyou

This post has been edited by doubts: 28 Nov, 2007 - 09:06 PM
User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: Check And Verify If A Program Is Running Or Not
28 Nov, 2007 - 10:14 PM
Post #8

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 9,481



Thanked: 161 times
Dream Kudos: 9050
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
If you're using Visual VC++ why are you posting this question in the Visual Basic Forum? Moving to the C and C++ Forum, you'll have better luck there than in a VB forum smile.gif
User is online!Profile CardPM
+Quote Post

skaoth
RE: Check And Verify If A Program Is Running Or Not
29 Nov, 2007 - 12:06 AM
Post #9

D.I.C Regular
Group Icon

Joined: 7 Nov, 2007
Posts: 356



Thanked: 12 times
Dream Kudos: 100
My Contributions
If I understand correctly you have 2 applications.
1 that keeps track of a timer and updates it every 10 secs.

The 2nd, I assume is also a GUI based application? If it is
then you can use the FindWindow() API to get a handle to the
2nd application (I don't know if FindWindow() works with a dos app)
User is online!Profile CardPM
+Quote Post

doubts
RE: Check And Verify If A Program Is Running Or Not
29 Nov, 2007 - 12:33 AM
Post #10

New D.I.C Head
*

Joined: 1 Nov, 2007
Posts: 17


My Contributions
I have used findwindow but that's not helping my task......
User is offlineProfile CardPM
+Quote Post

skaoth
RE: Check And Verify If A Program Is Running Or Not
29 Nov, 2007 - 09:07 AM
Post #11

D.I.C Regular
Group Icon

Joined: 7 Nov, 2007
Posts: 356



Thanked: 12 times
Dream Kudos: 100
My Contributions
Can you post the code of how you are using Findwindow().
It would also be helpful to see the code of how you created
the window for both application

thx

QUOTE(doubts @ 29 Nov, 2007 - 01:33 AM) *

I have used findwindow but that's not helping my task......


User is online!Profile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 1/7/09 09:14PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month