Home   Index   About
Ultimate Pack


Custom Search
IMarshal::MarshalInterface

Marshals an interface pointer into the stream, that is, writes the appropriate data into the stream so that your IMarshal::UnmarshalInterface method can use that data to initialize a proxy object in another process.

HRESULT IMarshal::MarshalInterface(

IStream *pStm,
//Stream used for marshaling
REFIID riid,
//Identifies interface being marshaled
void *pv,
//Points to interface pointer being marshaled
DWORD dwDestContext,
//Identifies destination process
void *pvDestContext,
//Reserved for future use
DWORD mshlflags
//Specifies reason for marshaling
);

Parameters

pStm

[in]Points to the stream to be used during marshaling.

riid

[in]Specifies the IID of the interface pointer to be marshaled.

pv

[in]Points to the interface pointer to be marshaled; can be NULL.

dwDestContext

[in] Specifies the destination context, that is, the process in which the unmarshaling will be done. Different marshaling can be done depending on whether the unmarshaling will happen on the local workstation or on a workstation on the network; it's possible for an object to do custom marshaling in one case but not another. The legal values for dwDestContext are taken from the enumeration MSHCTX. For information on the MSHCTX enumeration, see the "Data Structures" section.

pvDestContext

[in] Reserved for use with future MSHCTX values.

mshlflags

[in]Specifies why marshaling is taking place. The legal values for mshlflags are taken from the MSHLFLAGS enumeration. For information on the MSHLFLAGS enumeration, see the "Data Structures" section.

Return Values

S_OK

The interface pointer was marshaled successfully.

E_FAIL

Indicates that the implementation failed.

E_NOINTERFACE

The specified interface was not supported.

STG_E_MEDIUMFULL

The stream was full.

Comments

This method is called from the originating side (that is, the side doing the marshaling). This method sends information to the receiving side by writing that information into the stream; on the receiving side, the information will be read from the stream and used to initialize a proxy object.

Notes to Implementors

Your implementation of IMarshal::MarshalInterface must write to the stream whatever data is needed to initialize the proxy on the receiving side. Your implementation can delegate some destination contexts to the standard marshaling implementation, which is available by calling the CoGetStandardMarshal API function. You should always delegate if the dwDestContext parameter contains a value that your implementation does not understand; this allows new destination contexts to be defined in the future.

Your implementation cannot assume the stream is large enough to hold all the data; it must still take into account the possibility that the stream may return STG_E_MEDIUMFULL errors. Just before exiting, your implementation should position the seek pointer in the stream immediately after the last byte of data written.

Note that the data marshaled by IMarshal::MarshalInterface can be unmarshaled zero or more times; this may happen if the marshaled data is stored in a global table, from which it may be unmarshaled many times by different client processes. Marshalers must be able to handle the result of multiple unmarshalings. For example, suppose the unmarshaling process creates a proxy that forwards calls to a stub interface in the server application; this stub interface must be able to deal with zero or more proxies being created from the same initialization data.

If the pv parameter is NULL and your implementation needs that interface pointer, it can call IUnknown::QueryInterface on the current object to get it. The pv parameter exists merely to improve efficiency.

See Also

CoGetStandardMarshal, IMarshal::GetMarshalSizeMax, IMarshal::GetUnmarshalClass, IMarshal::UnmarshalInterface


Last news from Greatis Software

Nostalgia .Net     Nostalgia .Net     .Net is powerful, but not all-powerful, so sometimes we need to use Win32 API for our .Net applications. It's simple enough with Platform Invoke if you have Win32 skill, but we do not always have time to dig the ancient documentation, declare the special types that are compatible with Win32, find the values of the Win32's constants and so on. Nostalgia .Net offers several simple-to-use classes, and components that will allow you to forget about the headache of Win32 and just use the power of Win32 in your application the same way as you use the native. Net classes.  More »

Recommended software for developers

Ultimate Pack for Delphi and C++ Builder     Ultimate Pack     Component pack for Delphi and C++ Builder that contains runtime form designer, runtime object inspector, print suite and much more for the very special price.  More »

Form Designer .Net     Form Designer .Net     Unique runtime form design solution that allows to edit any form in .Net WinForms application at runtime with full source codes for only 300 euro!  More »

Print Suite .Net     Print Suite .Net     Print Suite .Net is a set of components for easy printing texts, images and grids from your WinForms applications. Full C# source codes are available  More »

Gradient Controls .Net     Gradient Controls .Net     Gradient Controls .Net offers controls with gradient background feature. Labels, panels and so on... Full C# source codes are available  More »

iGrid     Greatis iGrid     iGrid plots drawing grid right over your desktop, so you can use it everywhere, with any drawing application without any special plugins for different graphic editors.  More »


All the contacts and projects

Dmitry Vasiliev (just.dmitry)

Related Links

Software for Visual Studio .NET developers
Software for Delphi and C++ Builder developers
Software for Visual Basic 6 developers
Delphi Tips&Tricks
MegaDetailed.NET

More Online Helps

Win32 Programmer's Reference
Win32 Multimedia Programmer's Reference
OLE Programmer's Reference
Microsoft Windows Pen API Programmer's Reference
Microsoft Windows Sockets 2 Reference
Microsoft Windows Telephony API (TAPI) Programmer's Reference
Unix Manual Pages

Free Tech Secrets ;) Copyright © 2008-2012 Free Tech Secrets ;) greatis just4fun network just4fun