Remote COM registering

Sample Image

Environment: Windows NT 4 SP3, Visual C++ 5 (and greater)

This sample show how we can register components on a remote machine. For this purpose I build to projects. First it’s a COM used on remote machines to receive a component and register it. It can be also used to test if components can be instantiate at that location (so, if they have been succesfully registered). The second project is MFC based and help you to easely register and test components on remote machines.

ATL based component must be registered on remote machines to be used. To be usable it must be configured to run under an account that allow COM registering.

I don’t think that any line code is necessarely to be presented because source code is quite simple and commented. Please, fell free to send-me comments. Anyway, here is the IDL source my IRemoteReg interface.

To register a component on a remote machine where you have been previously register RemoteReg server contained in alx.exe you must first instantiate this component on that machine ( from your local machine ). After that you shud call Reset to prepare registration and NewServer to specify server file name and type (.dll, .exe, service).
You must send you component using chunks of data. The file will be reconstructed on remote machine in System32 directory. When you call Register this component consider that all data was sent and tries to register component on that machine.

If you want to test if a component was correctly registered on remote machine you can try to instantiate it on that machine in the same way we have been instaintate RemoteReg component.

interface IRemoteReg : IUnknown
{
 // Server type
 typedef enum
 {
  ServerType_Dll = 0,
  ServerType_Exe,
  ServerType_Service
 } ServerType;

 const long dwMaxChunkSize = 1024;

 // Chunk structure used to transfer data
 typedef struct
 {
  long m_dwSize;
  byte m_pData[1024];
 } Chunk;

 [helpstring("Prepare this object for receiving an new server for registering")]
 HRESULT Reset();
 [helpstring("Begins registering of a new server")]
 HRESULT NewServer([in] BSTR bstrServerName, [in] ServerType nType);
 [helpstring("Register server")]
 HRESULT Register();
 [helpstring("Append a new chunk to build server on remote machine")]
 HRESULT AppendChunk([in] Chunk* pChunk);
};

Downloads

Download demo project of my component (RemoteReg_comp.zip) – 52 Kb
Download demo project of my MFC based application (RemoteReg_demo.zip) – 11 Kb
Download source of my ATL based component (RemoteReg_atl_comp.zip) – 19 Kb
Download source of my MFC based application (RemoteReg_mfc_app.zip) – 26 Kb

More by Author

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Must Read