Click here to Skip to main content
15,897,165 members
Articles / Desktop Programming / Win32

Inter-Process Communication (IPC) Introduction and Sample Code

Rate me:
Please Sign up or sign in to vote.
4.91/5 (57 votes)
19 Dec 2009Ms-PL8 min read 251.7K   12.2K   195  
This article will cover general IPC technologies in All-In-One Code Framework. The IPC technologies include Named Pipes, File Mapping, MailSlot, etc.
/****************************** Module Header ******************************\
* Module Name:	ATLSimpleObjectSTA.h
* Project:		ATLActiveXExe
* Copyright (c) Microsoft Corporation.
* 
* Declare the component's implementation class CATLSimpleObjectSTA
* 
* This source is subject to the Microsoft Public License.
* See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
* All other rights reserved.
* 
* History:
* * 1/21/2009 11:03 PM Jialiang Ge Created
\***************************************************************************/

#pragma once

#pragma region Includes
#include "resource.h"       // main symbols

#include "ATLActiveXExe_i.h"
#pragma endregion


#if defined(_WIN32_WCE) && !defined(_CE_DCOM) && !defined(_CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA)
#error "Single-threaded COM objects are not properly supported on Windows CE platform, such as the Windows Mobile platforms that do not include full DCOM support. Define _CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA to force ATL to support creating single-thread COM object's and allow use of it's single-threaded COM object implementations. The threading model in your rgs file was set to 'Free' as that is the only threading model supported in non DCOM Windows CE platforms."
#endif


// CATLSimpleObjectSTA

class ATL_NO_VTABLE CATLSimpleObjectSTA :
	public CComObjectRootEx<CComSingleThreadModel>,
	public CComCoClass<CATLSimpleObjectSTA, &CLSID_ATLSimpleObjectSTA>,
	public IDispatchImpl<IATLSimpleObjectSTA, &IID_IATLSimpleObjectSTA, &LIBID_ATLActiveXExeLib, /*wMajor =*/ 1, /*wMinor =*/ 0>
{
public:
	CATLSimpleObjectSTA()
	{
	}

DECLARE_REGISTRY_RESOURCEID(IDR_ATLSIMPLEOBJECTSTA)


BEGIN_COM_MAP(CATLSimpleObjectSTA)
	COM_INTERFACE_ENTRY(IATLSimpleObjectSTA)
	COM_INTERFACE_ENTRY(IDispatch)
END_COM_MAP()



	DECLARE_PROTECT_FINAL_CONSTRUCT()

	HRESULT FinalConstruct()
	{
		return S_OK;
	}

	void FinalRelease()
	{
	}

public:

	STDMETHOD(HelloWorld)(BSTR* pRet);
	STDMETHOD(get_FloatProperty)(FLOAT* pVal);
	STDMETHOD(put_FloatProperty)(FLOAT newVal);
	STDMETHOD(GetProcessThreadID)(LONG* pdwProcessId, LONG* pdwThreadId);
protected:
	// Used by FloatProperty
	float m_fField;
};

OBJECT_ENTRY_AUTO(__uuidof(ATLSimpleObjectSTA), CATLSimpleObjectSTA)

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 Microsoft Public License (Ms-PL)


Written By
China China
Microsoft All-In-One Code Framework delineates the framework and skeleton of Microsoft development techniques through typical sample codes in three popular programming languages (Visual C#, VB.NET, Visual C++). Each sample is elaborately selected, composed, and documented to demonstrate one frequently-asked, tested or used coding scenario based on our support experience in MSDN newsgroups and forums. If you are a software developer, you can fill the skeleton with blood, muscle and soul. If you are a software tester or a support engineer like us, you may extend the sample codes a little to fit your specific test scenario or refer your customer to this project if the customer's question coincides with what we collected.
http://cfx.codeplex.com/

Comments and Discussions