ISurrogate

ISurrogate defines two methods: one for dynamically loading new DLL servers into an existing surrogate, and one to free the surrogate when it is no longer needed.

A surrogate is an EXE process into which a DLL server can be loaded to give the DLL server the advantages of an EXE server without the coding overhead. It can also allow independent DLL servers to be located together within a single process, reducing the total number of processes needed. DLL servers are easy to write using standard development tools like Microsoft® Visual Basic®, Microsoft® Visual J++™, and Microsoft Developer Studio™, and running them in a surrogate process provides the benefits of an executable implementation, including fault isolation, the ability to serve multiple clients simultaneously, and allowing the server to provide services to remote clients in a distributed environment.

When to Implement

If you are using the system-supplied surrogate, which implements this interface, you do not need to implement it specifically. All surrogate processes must implement this interface, so if you are writing a custom surrogate, you must implement it along with IUnknown, IClassFactory, and IMarshal.

When to Use

In general, you would not call the methods of ISurrogate directly. COM calls the LoadDllServer method when there is an activation request for a class registered with the DllSurrogate named-value. COM also calls FreeSurrogate when all DLL servers running in the surrogate have terminated.

Methods in Vtable Order

IUnknown Methods Description
QueryInterface Returns pointers to supported interfaces.
AddRef Increments reference count.
Release Decrements reference count.

ISurrogate Methods Description
LoadDllServer Creates an uninitialized object.
FreeSurrogate Locks object application open in memory.

QuickInfo

  Windows NT: Use version 4.0 SP2 or later.
  Windows: Use Windows 95 or later.
  Windows CE: Unsupported.
  Header: Declared in objidl.h.

See Also

Writing a Custom Surrogate, DLL Surrogates, ISurrogate::LoadDllServer, ISurrogate::FreeSurrogate