Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version
Go to top

Remote Processes and Machine control of Windows NT based systems (2000/XP)

, 1 Apr 2012
Control certain aspects of machines sitting remotely, without having to install and trigger an application on the remote machine.
#ifndef MACHINEINFO_H
#define MACHINEINFO_H

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

#include <afxtempl.h>
#include <Tlhelp32.h>

struct SProcessInfo
{
    PROCESSENTRY32 peProcessEntry;
    SIZE_T         stMemUsage;
};

//typedef CTypedPtrList<CPtrList, PROCESSENTRY32*> CProcessInfoList;
typedef CTypedPtrList<CPtrList, SProcessInfo*> CProcessInfoList;



class CMachineInfo : public CObject  
{
    DECLARE_SERIAL(CMachineInfo)
public:
	CMachineInfo();
	virtual ~CMachineInfo();

    void SetIP(CString strIP);
    CString GetIP();

    void SetPassword(CString strPwd);
    CString GetPassword();

    void SetLogon(CString m_strLogon);
    CString GetLogon();

    void SetRemoteAdminPipe(HANDLE handle);
    HANDLE GetRemoteAdminPipe();

    void SetRemoteAdminProcessInfoPipe(HANDLE handle);
    HANDLE GetRemoteAdminProcessInfoPipe();

    void SetRemoteAdminProcessExecutePipe(HANDLE handle);
    HANDLE GetRemoteAdminProcessExecutePipe();

    void SetRemoteAdminProcessKillPipe(HANDLE handle);
    HANDLE GetRemoteAdminProcessKillPipe();

    void SetRemoteAdminSysShutDownPipe(HANDLE handle);
    HANDLE GetRemoteAdminSysShutDownPipe();

    CMachineInfo& operator = (CMachineInfo& miMachineInfo); /* Assignment operator */
    BOOL operator == (CMachineInfo& miMachineInfo);

    void RefreshProcessList(CProcessInfoList& pilList);
    CProcessInfoList* GetProcessInfoList();

    void ClosePipeHandles();
    void SendEndThreadMessage();
    
    virtual void Serialize(CArchive& ar);

protected:
    CString m_strIP;
    CString m_strPwd;
    CString m_strLogon;
    CProcessInfoList m_pilProcessList;
    HANDLE m_hRemoteAdminPipe;
    HANDLE m_hRemoteAdminProcessInfoPipe;
    HANDLE m_hRemoteAdminProcessExecutePipe;
    HANDLE m_hRemoteAdminProcessKillPipe;
    HANDLE m_hRemoteAdminSysShutDownPipe;
};


inline void CMachineInfo::SetIP(CString strIP)
{
    m_strIP = strIP;
}

inline CString CMachineInfo::GetIP()
{
    return m_strIP;
}

inline void CMachineInfo::SetPassword(CString strPwd)
{
    m_strPwd = strPwd;
}

inline CString CMachineInfo::GetPassword()
{
    return m_strPwd;
}

inline void CMachineInfo::SetLogon(CString strLogon)
{
    m_strLogon = strLogon;
}

inline CString CMachineInfo::GetLogon()
{
    return m_strLogon;
}

inline void CMachineInfo::SetRemoteAdminPipe(HANDLE handle)
{
    m_hRemoteAdminPipe = handle;
}

inline HANDLE CMachineInfo::GetRemoteAdminPipe()
{
    return m_hRemoteAdminPipe;
}

inline void CMachineInfo::SetRemoteAdminProcessInfoPipe(HANDLE handle)
{
    m_hRemoteAdminProcessInfoPipe = handle;
}

inline HANDLE CMachineInfo::GetRemoteAdminProcessInfoPipe()
{
    return m_hRemoteAdminProcessInfoPipe;
}

inline void CMachineInfo::SetRemoteAdminProcessExecutePipe(HANDLE handle)
{
    m_hRemoteAdminProcessExecutePipe = handle;
}

inline HANDLE CMachineInfo::GetRemoteAdminProcessExecutePipe()
{
    return m_hRemoteAdminProcessExecutePipe;
}

inline void CMachineInfo::SetRemoteAdminProcessKillPipe(HANDLE handle)
{
    m_hRemoteAdminProcessKillPipe = handle;
}

inline HANDLE CMachineInfo::GetRemoteAdminProcessKillPipe()
{
    return m_hRemoteAdminProcessKillPipe;
}

inline void CMachineInfo::SetRemoteAdminSysShutDownPipe(HANDLE handle)
{
    m_hRemoteAdminSysShutDownPipe = handle;
}

inline HANDLE CMachineInfo::GetRemoteAdminSysShutDownPipe()
{
    return m_hRemoteAdminSysShutDownPipe;
}
#endif // MACHINEINFO_H

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)

Share

About the Author

Prateek Kaul
Web Developer
India India
No Biography provided

| Advertise | Privacy | Mobile
Web03 | 2.8.140926.1 | Last Updated 1 Apr 2012
Article Copyright 2003 by Prateek Kaul
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid