GME  13
CSGUIInterop.cpp
Go to the documentation of this file.
00001 #include "StdAfx.h"
00002 
00003 #include <direct.h>
00004 
00005 #import "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorlib.tlb" no_implementation
00006 #import "CSGUI.tlb" no_implementation
00007 
00008 #import "CSGUI.tlb" implementation_only
00009 
00010 #pragma comment(linker, "\"/manifestdependency:type='win32' processorArchitecture='msil' name='CSGUI' version='1.0.0.0' language='*'\"")
00011 
00012 static HRESULT IsolationAwareCoCreateInstance_(const IID& clsid, const IID& iid, void** out)
00013 {
00014         ULONG_PTR cookie;
00015         BOOL succ = IsolationAwareActivateActCtx(0, &cookie);
00016         ASSERT(succ);
00017         HRESULT hr = CoCreateInstance(clsid, 0, CLSCTX_ALL, iid, (void**)out);
00018         succ = IsolationAwareDeactivateActCtx(0, cookie);
00019         ASSERT(succ);
00020         return hr;
00021 }
00022 
00023 void MoveReferenceWithRefportConnectionsAndWriteToConsole(IMgaFCO* target, IMgaReference* ref)
00024 {
00025         using namespace CSGUI;
00026         _ReferenceSwitcherPtr switcher;
00027         // n.b. RS is the coclass, _RS is the interface
00028         HRESULT hr = IsolationAwareCoCreateInstance_(__uuidof(ReferenceSwitcher), __uuidof(_ReferenceSwitcherPtr), (void**) &switcher);
00029         if (FAILED(hr))
00030                 throw hresult_exception(E_MGA_REFPORTS_USED);
00031         switcher->SwitchReference(target, ref);
00032 }