Click here to Skip to main content
15,883,647 members
Articles / Programming Languages / C

COM in plain C, Part 2

Rate me:
Please Sign up or sign in to vote.
4.96/5 (98 votes)
20 Apr 2006CPOL39 min read 274.7K   6.2K   165  
How to write a COM component in C that can be used by script languages such as VBscript, Visual BASIC, jscript, etc.
// The IDL file for IExample2.DLL
//
// {4370990C-5481-4901-BF01-CF0F298D923C} = Type library's GUID
// {30D789C0-553A-4f36-A13B-807A3003FDC0} = IExample2 object's GUID
// {112BD761-DE08-4e94-95F7-473E3CEFE26A} = IExample2 VTable's GUID

[uuid(4370990C-5481-4901-BF01-CF0F298D923C), version(1.0), helpstring("IExample2 COM server")]
library IExample2
{
	importlib("STDOLE2.TLB");

	[uuid(112BD761-DE08-4e94-95F7-473E3CEFE26A), dual, oleautomation, hidden, nonextensible]
	interface IExample2VTbl : IDispatch
	{
		[helpstring("Sets the test string.")]
		[id(1), propput] HRESULT Buffer([in] BSTR);
		[helpstring("Gets the test string.")]
		[id(1), propget] HRESULT Buffer([out, retval] BSTR *);
	};

	[uuid(30D789C0-553A-4f36-A13B-807A3003FDC0), helpstring("IExample2 object."), appobject]
	coclass IExample2
	{
		[default] interface IExample2VTbl;
	}
}

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
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions