3,245
社区成员
发帖
与我相关
我的任务
分享
// Created by Microsoft (R) C/C++ Compiler Version 15.00.30729.01 (16016968).
//
// f:\my documents\visual studio 2008\projects\ex_vs9_com\test3\debug\cscomtest.tlh
//
// C++ source equivalent of Win32 type library cscomtest.tlb
// compiler-generated file created 10/21/09 at 18:28:40 - DO NOT EDIT!
#pragma once
#pragma pack(push, 8)
#include <comdef.h>
namespace cscomtest {
//
// Forward references and typedefs
//
struct __declspec(uuid("0b8a6e50-19e5-4b64-8fcc-c45199656fe6"))
/* LIBID */ __cscomtest;
struct __declspec(uuid("47c976e0-c208-4740-ac42-41212d3c34f0"))
/* dispinterface */ MyCom_Events;
struct __declspec(uuid("368c19c3-a726-49b5-a2d8-482680adda1d"))
/* dual interface */ IMyCom;
struct /* coclass */ MyCom;
struct /* coclass */ OKHander;
struct __declspec(uuid("4c0dcd67-7bd0-3249-86e8-cedc6f13e676"))
/* dual interface */ _OKHander;
//
// Smart pointer typedef declarations
//
_COM_SMARTPTR_TYPEDEF(MyCom_Events, __uuidof(MyCom_Events));
_COM_SMARTPTR_TYPEDEF(IMyCom, __uuidof(IMyCom));
_COM_SMARTPTR_TYPEDEF(_OKHander, __uuidof(_OKHander));
//
// Type library items
//
struct __declspec(uuid("47c976e0-c208-4740-ac42-41212d3c34f0"))
MyCom_Events : IDispatch
{
//
// Wrapper methods for error-handling
//
// Methods:
HRESULT OK ( );
};
struct __declspec(uuid("368c19c3-a726-49b5-a2d8-482680adda1d"))
IMyCom : IDispatch
{
//
// Wrapper methods for error-handling
//
long Add (
long a,
long b );
HRESULT ThrowException1 ( );
HRESULT ThrowException2 ( );
HRESULT ThrowException3 ( );
HRESULT OnOK ( );
//
// Raw methods provided by interface
//
virtual HRESULT __stdcall raw_Add (
/*[in]*/ long a,
/*[in]*/ long b,
/*[out,retval]*/ long * pRetVal ) = 0;
virtual HRESULT __stdcall raw_ThrowException1 ( ) = 0;
virtual HRESULT __stdcall raw_ThrowException2 ( ) = 0;
virtual HRESULT __stdcall raw_ThrowException3 ( ) = 0;
virtual HRESULT __stdcall raw_OnOK ( ) = 0;
};
struct __declspec(uuid("498627af-bcd0-4a1f-95e4-739953847b60"))
MyCom;
// interface _Object
// [ default ] interface IMyCom
// [ default, source ] dispinterface MyCom_Events
struct __declspec(uuid("f2ab1b1c-26c1-3a16-933e-f52135b61f45"))
OKHander;
// [ default ] interface _OKHander
// interface _Delegate
// interface _Object
// interface ICloneable
// interface ISerializable
struct __declspec(uuid("4c0dcd67-7bd0-3249-86e8-cedc6f13e676"))
_OKHander : IDispatch
{};
//
// Named GUID constants initializations
//
extern "C" const GUID __declspec(selectany) LIBID_cscomtest =
{0x0b8a6e50,0x19e5,0x4b64,{0x8f,0xcc,0xc4,0x51,0x99,0x65,0x6f,0xe6}};
extern "C" const GUID __declspec(selectany) DIID_MyCom_Events =
{0x47c976e0,0xc208,0x4740,{0xac,0x42,0x41,0x21,0x2d,0x3c,0x34,0xf0}};
extern "C" const GUID __declspec(selectany) IID_IMyCom =
{0x368c19c3,0xa726,0x49b5,{0xa2,0xd8,0x48,0x26,0x80,0xad,0xda,0x1d}};
extern "C" const GUID __declspec(selectany) CLSID_MyCom =
{0x498627af,0xbcd0,0x4a1f,{0x95,0xe4,0x73,0x99,0x53,0x84,0x7b,0x60}};
extern "C" const GUID __declspec(selectany) CLSID_OKHander =
{0xf2ab1b1c,0x26c1,0x3a16,{0x93,0x3e,0xf5,0x21,0x35,0xb6,0x1f,0x45}};
extern "C" const GUID __declspec(selectany) IID__OKHander =
{0x4c0dcd67,0x7bd0,0x3249,{0x86,0xe8,0xce,0xdc,0x6f,0x13,0xe6,0x76}};
//
// Wrapper method implementations
//
#include "f:\my documents\visual studio 2008\projects\ex_vs9_com\test3\debug\cscomtest.tli"
} // namespace cscomtest
#pragma pack(pop)
// TODO: code your application's behavior here.
try
{
CoInitialize(NULL);//NULL换成0也可以
cscomtest::IMyComPtr pIMyCom(__uuidof(cscomtest::MyCom));
cout<<"out:"<<pIMyCom->Add(1,2)<<endl;
//pIMyCom->ThrowException1();
//cscomtest::_OKHanderPtr
IConnectionPointContainer* pp;
pIMyCom.QueryInterface(IID_IConnectionPointContainer,(void**)&pp);
IConnectionPoint* p2;
pp->FindConnectionPoint(DIID_MyCom_Events,&p2);
CoUninitialize();
}
catch (_com_error& e)
{
cerr<<e.Description();
}