Click here to Skip to main content
14,025,710 members
Click here to Skip to main content

Tagged as


102 bookmarked
Posted 31 Aug 2003
Licenced CPOL

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.
#include "stdafx.h"
#include "ConnectionThread.h"
#include "Command.h"
#include "RemoteAdminView.h"
#include "RemoteAdminDoc.h"
#include "MachineView.h"
#include "GlobalHelperFunc.h"

UINT __stdcall ThreadConnection::ConnectToMachine(void* pParam)
    SConnectInfo* pConnectInfo = reinterpret_cast<SConnectInfo*>(pParam);

    CRemoteAdminDoc* pDoc              = pConnectInfo->pDoc;
    CRemoteAdminView* pRemoteAdminView = pConnectInfo->pRemoteAdminView;
    CMachineView* pMachineView         = pConnectInfo->pMachineView;
    CString strIP                      = pConnectInfo->strIP;
    CString strPwd                     = pConnectInfo->strPwd;
    // Add to the connection pending list, so that even if someone requests
    // connection for the same machine it will fail.

    BOOL bConnectOk = pDoc->EstablishAllConnections(strIP, strPwd, TRUE, pMachineView, pRemoteAdminView);

    if (!bConnectOk)
        CString strFromatAPIMsg = ErrorHandling::FormatLastError();
        CString strDisplayMsg;
        strDisplayMsg.Format("Machine IP %s: %s", strIP.GetBuffer(0), strFromatAPIMsg.GetBuffer(0));
        // Since one machine has connected, resume the process updation thread
        // This will be called more than once, when every new nachine is conncted.
        // It will only be an extra call, but dosen't harm, we just need to
        // trigger iti
        int iTotalMachineBeingMonitored = pDoc->GetTotalMachinesMonitored();
        if (iTotalMachineBeingMonitored == 0) 
            // Clean the list view
        else  // Select the latest machine added and show it's processes
            HTREEITEM h = pMachineView->GetTreeItemForText(strIP);

            if (h != NULL)
                //pMachineView->GetTreeCtrl().Select(h, TVGN_CARET);
    // Since the pending connection request is over (failed or succeded), now remove
    // it from the pending connection list

	if (pConnectInfo)
		delete pConnectInfo;
    return 0;

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.


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


About the Author

Prateek Kaul
Web Developer
India India
No Biography provided

You may also be interested in...

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web03 | 2.8.190419.4 | Last Updated 1 Apr 2012
Article Copyright 2003 by Prateek Kaul
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid