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


Comments

  • Registering ActiveX DLLs

    Posted by Legacy on 01/01/2002 12:00am

    Originally posted by: Yami

    How can this be done in VB/VBScript to register ActiveX DLLs on Remote Server, Please Help if you can
    

    Reply
  • How to run DCOMTest on different machine?

    Posted by Legacy on 10/18/2001 12:00am

    Originally posted by: roc

    MSDN provides the "Simple Network OLE Sample", which include two exe files: sserver.exe and sclient.exe. They work well on the same machine. But, when I put them on differen machine, the sserver just says "waiting...", and the client reply CoCreateInstanceEx error. The servre machine is Win2K server, the client server is Win2K server or Win98. I have added the user account and password of the component on server machine using DCOMCNFG.EXE. Is it wrong?
    How to use DCOMCFNG.EXE to make them usable then? Please help me!

    Reply
  • Bad dsw

    Posted by Legacy on 04/10/2000 12:00am

    Originally posted by: Zohar

    You have forgot to include some files in your source code sample. There is a missing project.

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Java developers know that testing code changes can be a huge pain, and waiting for an application to redeploy after a code fix can take an eternity. Wouldn't it be great if you could see your code changes immediately, fine-tune, debug, explore and deploy code without waiting for ages? In this white paper, find out how that's possible with a Java plugin that drastically changes the way you develop, test and run Java applications. Discover the advantages of this plugin, and the changes you can expect to see …

  • Protecting business operations means shifting the priorities around availability from disaster recovery to business continuity. Enterprises are shifting their focus from recovery from a disaster to preventing the disaster in the first place. With this change in mindset, disaster recovery is no longer the first line of defense; the organizations with a smarter business continuity practice are less impacted when disasters strike. This SmartSelect will provide insight to help guide your enterprise toward better …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds