Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Understanding Classic COM Interoperability With .NET Applications

, 24 Jul 2001
Discusses how existing COM components can be used from managed code.
cominteropwithdotnetdemo.zip
COMInteropWithDOTNET
COMInteropWithDOTNETDemo
AirlineNotifyMetadata.dll
AirlineMetadata.dll
SevenDwarfs.exe
IceCreamMenuClient.exe
HelloWorldDelegate.exe
FlightClient.exe
DelegateTest.exe
AirlineNotifyClient.exe
WeatherNotify.dll
AirlineInformation.dll
AirlineNotify.exe
IceCreamParlor.dll
MyFlyer.dll
NETThreadDemoClient.exe
ControlTower.exe
VBIceCreamProject.dll
VBTestClient.exe
VBWeatherStation.exe
AirlineClient.exe
Temperature.dll
MyFlyerMetadata.dll
IceCreamMenuMetadata.dll
HelloDotNet.dll
Directional.dll
cominteropwithdotnetsource.zip
COMInteropWithDOTNETSource
DOTNET-CSharpFiles
MyKeyPair.snk
AirlineInformation.tlb
IceCreamParlor.tlb
AirlineNotify.tlb
MyFlyer.tlb
ClassicCOM
AirlineNotify
AirlineNotifyps.def
AirlineNotifyps.mk
AirlineNotify.rgs
AirlineNotify.dsw
AirlineArrivalPager.rgs
AirlineNotify.aps
AirlineNotify.dsp
AirlineNotify.suo
AirlineNotify.tlb
AirlineNotify.opt
AirlineInformation
AirlineInfo.rgs
AirlineInformation.aps
AirlineInformation.def
AirlineInformationps.def
AirlineInformationps.mk
AirlineInformation.dsp
AirlineInformation.dsw
AirlineInformation.tlb
AirlineInformation.opt
VBIceCreamParlor
IceCreamMenu.cls
stdole.dll
VBIceCreamProject.vbw
VBIceCreamProject.lib
VBIceCreamProject.exp
VBIceCreamProject.vbp
VBAirlineControlTower
MainForm.frm
ControlTower.vbw
ControlTower.vbp
IceCreamParlor
IceCreamMenu.rgs
IceCreamParlor.def
IceCreamParlor.aps
IceCreamParlorps.def
IceCreamParlorps.mk
IceCreamParlor.dsp
IceCreamParlor.dsw
IceCreamParlor.tlb
IceCreamParlor.opt
MyFlyer
MyFlyer.dsp
MyFlyer.def
MyFlyerps.def
MyFlyerps.mk
MyFlyer.dsw
Flyer.rgs
MyFlyer.aps
MyFlyer.tlb
MyFlyer.opt
VBTestClient
VBTestClient.vbp
FormMain.frm
VBTestClient.vbw
VBWeatherStation
VBWeatherStation.vbw
VBWeatherStationForm.frm
VBWeatherStation.vbp
NETThreadDemoClient
NETThreadDemoClient.opt
NETThreadDemoClient.dsp
NETThreadDemoClient.dsw
HelloDotNet.tlb
cominterop_demo.zip
ComInteropDemo
AirlineCSharpClient
AirlineInformation
AirlineInformation.opt
AirlineInfo.rgs
AirlineInformation.aps
AirlineInformation.tlb
AirlineInformation.def
AirlineInformationps.def
AirlineInformationps.mk
AirlineInformation.dsp
AirlineInformation.dsw
// AirlineInfo.cpp : Implementation of CAirlineInfo
#include "stdafx.h"
#include "comdef.h"
#include <time.h>
#include "AirlineInformation.h"
#include "AirlineInfo.h"

/////////////////////////////////////////////
// ERROR CODES
/////////////////////////////////////////////
#define AIRLINE_NOT_FOUND 0x80040002L

/////////////////////////////////////////////////////////////////////////////
// CAirlineInfo

/*
***************************************************************************
** FUNCTION: InterfaceSupportsErrorInfo
** DESCRIPTION: 
** PARAMETERS: 
**  (REFIID)riid
** RETURN VALUES: (STDMETHODIMP)
***************************************************************************
*/
STDMETHODIMP CAirlineInfo::InterfaceSupportsErrorInfo(REFIID riid)
{
	static const IID* arr[] = 
	{
		&IID_IAirlineInfo
	};
	for (int i=0; i < sizeof(arr) / sizeof(arr[0]); i++)
	{
		if (InlineIsEqualGUID(*arr[i],riid))
			return S_OK;
	}
	return S_FALSE;
}

/*
***************************************************************************
** FUNCTION: GetAirlineTiming
** DESCRIPTION: 
** PARAMETERS: 
**  (BSTR)bstrAirline
**  (BSTR)*pBstrTiming
** RETURN VALUES: (STDMETHODIMP)
***************************************************************************
*/
STDMETHODIMP CAirlineInfo::GetAirlineTiming(BSTR bstrAirline, BSTR *pBstrDetails)
{

	_bstr_t bstrQueryAirline(bstrAirline);
	if(NULL == pBstrDetails) return E_POINTER;
	
	// Check to see if this airline was found
	if(_bstr_t("Air Scooby IC 5678") == bstrQueryAirline)
	{
		// Return the timing for this Airline
		*pBstrDetails = _bstr_t(_T("16:45:00 - Will arrive at Terminal 3")).copy();

	}//if
	else
	{
		// Raise an error message 
		// (The Airline was not found)
		return Error(LPCTSTR(_T("Airline Timings not available for this Airline")), 
							  __uuidof(AirlineInfo),AIRLINE_NOT_FOUND);
	}

	return S_OK;
}


/*
***************************************************************************
** FUNCTION: GetInternetCafeLocations
** DESCRIPTION: 
** PARAMETERS: 
**  (BSTR *)pBstrLocationDetails
** RETURN VALUES: (STDMETHODIMP)
***************************************************************************
*/
STDMETHODIMP CAirlineInfo::GetInternetCafeLocations(BSTR * pBstrLocationDetails)
{
	// Check pointer validity
	if(pBstrLocationDetails == NULL) return E_POINTER;

	// Return the nearest location to the caller
	*pBstrLocationDetails = _bstr_t("Your nearest Internet Cafe is at Pavilion 3 in "
		"Terminal 2 - John Doe's Browse & Sip Cafe").copy();

	// Return the status
	return S_OK;


}

/*
***************************************************************************
** FUNCTION: get_LocalTimeAtOrlando
** DESCRIPTION: 
** PARAMETERS: 
**  (BSTR)*pVal
** RETURN VALUES: (STDMETHODIMP)
***************************************************************************
*/
STDMETHODIMP CAirlineInfo::get_LocalTimeAtOrlando(BSTR *pVal)
{
	
	// Local variables
	tm *tmLocalTime;
	time_t timeSys;

	// Get the System time
	time(&timeSys);

	//convert to time_t structure to a tm structure
	tmLocalTime = localtime(&timeSys);

	// Get the string equivalent of the tm structure
	*pVal = _bstr_t(asctime(tmLocalTime)).copy();

	// Return the status to the caller
	return S_OK;


}

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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Aravind C

India India
No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.141216.1 | Last Updated 25 Jul 2001
Article Copyright 2001 by Aravind C
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid