Click here to Skip to main content
15,886,258 members
Articles / Programming Languages / C++

Understanding Custom Marshaling Part 1

Rate me:
Please Sign up or sign in to vote.
4.97/5 (53 votes)
18 Aug 2006CPOL31 min read 206.9K   1.4K   147  
Learn the fundamental principles of COM custom marshaling by code examples.
// BasicSample01Interfaces.idl : IDL source for BasicSample01Interfaces
//

// This file will be processed by the MIDL tool to
// produce the type library (BasicSample01Interfaces.tlb) and marshalling code.

import "oaidl.idl";
import "ocidl.idl";

[
	object,
	uuid(BF0DC81A-46FB-4300-88E5-2B8EEB2CEEA1),
	dual,
	nonextensible,
	helpstring("IImmutable Interface"),
	pointer_default(unique)
]
interface IImmutable : IDispatch{
	[propget, id(1), helpstring("property LongValue")] HRESULT LongValue([out, retval] LONG* pVal);
};
[
	object,
	uuid(CCAB57EA-A497-44C0-B0A4-E781B7F47AA9),
	dual,
	nonextensible,
	helpstring("IImmutableObjectFactory Interface"),
	pointer_default(unique)
]
interface IImmutableObjectFactory : IDispatch{
	[id(1), helpstring("method CreateObject")] HRESULT CreateObject([in] LONG InitializationValue, [out,retval] IImmutable** ppIImmutableObjectReceiver);
};
[
	uuid(A5497E3E-1EAA-4E6D-BE52-1AC9DE0D2E61),
	version(1.0),
	helpstring("BasicSample01Interfaces 1.0 Type Library")
]
library BasicSample01InterfacesLib
{
	importlib("stdole2.tlb");
	[
		uuid(5F2C7BC5-0455-422A-B244-D1132C07218C),
		helpstring("Immutable Class")
	]
	coclass Immutable
	{
		[default] interface IImmutable;
	};
	[
		uuid(7324F66F-3F41-4BA9-8426-3D1B5DE4DD9C),
		helpstring("ImmutableObjectFactory Class")
	]
	coclass ImmutableObjectFactory
	{
		[default] interface IImmutableObjectFactory;
	};
};

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.

License

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


Written By
Systems Engineer NEC
Singapore Singapore
Lim Bio Liong is a Specialist at a leading Software House in Singapore.

Bio has been in software development for over 10 years. He specialises in C/C++ programming and Windows software development.

Bio has also done device-driver development and enjoys low-level programming. Bio has recently picked up C# programming and has been researching in this area.

Comments and Discussions