Click here to Skip to main content
15,895,799 members
Articles / Desktop Programming / MFC

Which machines in my LAN are running X DBMS

Rate me:
Please Sign up or sign in to vote.
3.00/5 (3 votes)
10 Jun 2009CPOL4 min read 25.5K   245   15  
Use NetServerEnum to find servers running particular services.
#if !defined(AFX_MACHINEINFO1_H__693B664D_0861_4723_ABD4_33786576DBED__INCLUDED_)
#define AFX_MACHINEINFO1_H__693B664D_0861_4723_ABD4_33786576DBED__INCLUDED_

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

class CServiceInfo : public CObject
{
public:
    CServiceInfo() {}
    CServiceInfo( LPCTSTR lpszName, LPCTSTR lpszStatus )
        : m_strName(lpszName), m_strStatus(lpszStatus)
    {
    }

    virtual ~CServiceInfo() {}

    CString GetName( void ) const { return m_strName; }
    CString GetStatus( void ) const { return m_strStatus; }

#ifdef _DEBUG
	virtual void AssertValid() const
    {
        CObject::AssertValid();

        ASSERT(! m_strName.IsEmpty());
    }
	
    virtual void Dump(CDumpContext& dc) const
    {
        CObject::Dump(dc);

        dc << _T("Service name = ") << m_strName << "\n";
        dc << _T("Status = ") << m_strStatus << "\n";
    }
#endif
    
private:
    CString m_strName;
    CString m_strStatus;
};

typedef CArray<CServiceInfo*, CServiceInfo*> CServiceInfoArray;

//====================================================================

class CMachineInfo : public CObject
{
public:
    CMachineInfo() {}
    CMachineInfo( LPCTSTR lpszName )
        : m_strName(lpszName)
    {
    }

    virtual ~CMachineInfo()
    {
        for (int x = 0; x < m_arrServices.GetSize(); x++)
            delete (CServiceInfo *) m_arrServices.GetAt(x);
    }
    
    int AddService( CServiceInfo *pServiceInfo ) { return m_arrServices.Add(pServiceInfo); }

    CString GetName( void ) const { return m_strName; }
    void GetServices( CServiceInfoArray &arr ) const
    {
        arr.Copy(m_arrServices);
    }

    /*
    const CServiceInfoArray& GetServices( void ) const
    {
        return m_arrServices;
    }
    */

#ifdef _DEBUG
	virtual void AssertValid() const
    {
        CObject::AssertValid();

        ASSERT(! m_strName.IsEmpty());
    }

	virtual void Dump(CDumpContext& dc) const
    {
        CObject::Dump(dc);

        dc << _T("Machine name = ") << m_strName << "\n";

        for (int x = 0; x < m_arrServices.GetSize(); x++)
            m_arrServices.GetAt(x)->Dump(dc);
    }
#endif

private:
    CString m_strName;
    CServiceInfoArray m_arrServices;
};

typedef CArray<CMachineInfo*, CMachineInfo*> CMachineInfoArray;

#endif // !defined(AFX_MACHINEINFO1_H__693B664D_0861_4723_ABD4_33786576DBED__INCLUDED_)

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Pinnacle Business Systems
United States United States

The page you are looking for might have been removed, had its name changed, or is temporarily unavailable.

HTTP 404 - File not found
Internet Information Services

Comments and Discussions