ITPub博客

首页 > 应用开发 > IT综合 > Developing COM Components using VC-ATL(3-7) (转)

Developing COM Components using VC-ATL(3-7) (转)

原创 IT综合 作者:amyz 时间:2007-08-17 10:55:41 0 删除 编辑
Developing COM Components using VC-ATL(3-7) (转)[@more@]XML:namespace prefix = o ns = "urn:schemas-microsoft-com:Office:office" />

最后让我们分析一下C:VCTestVCComProjDebugValidateCreditCardServer.tlh作为Developing com Components using VC-ATL(3)的结尾吧。

ValidateCreditCardServer.tlh清单

 


// Created by Microsoft (R) C/C++ Compiler Version 12.00.8168.0 (ad98f509).

//

// c:vctestvccomprojdebugValidateCreditCardServer.tlh

//

// C++ source equivalent of win32 type library ..ValidateCreditCardServerDebugValidateCreditCardServer.dll

// compiler-generated file created 2003" Day="19" Month="12">12/19/03 at 03:29:03 - DO NOT EDIT!

#pragma once

#pragma pack(push, 8)

#include

namespace VALIDATECREDITCARDSERVERLib {…………………………………..………名字空间

//

// Forward references and typedefs

//

struct /* coclass */ ValidateCard;………………………………………………………………..….. 组件类

struct __declspec(uuid("b1d1c73c-e340-4fdc-8734-92ecec64dc4e"))

/* dual interface */ IValidateCard;………………………………………………….………………用户接口

//

// Smart pointer typedef declarations

//

_COM_SMARTPTR_TYPEDEF(IValidateCard, __uuidof(IValidateCard));………..………智能指针

//

// Type library items

//

struct __declspec(uuid("c79635d2-7b86-4b20-a83c-0565dca54c3c"))…………………组件类CLSID

ValidateCard;

  // [ default ] interface IValidateCard

struct __declspec(uuid("b1d1c73c-e340-4fdc-8734-92ecec64dc4e"))……………………用户接口IID

IValidateCard : IDispatch

{

  //

  // Wrapper methods for error-handling

  //

  long ValidateCreditCard (

  _bstr_t bstrCCNo,

  _bstr_t bstrCCType );

  HRESULT LuhnCheck (

  _bstr_t bstrCCNo,

  _bstr_t bstrCCType );

  HRESULT LengthCheck (

  _bstr_t bstrCCNo,

  _bstr_t bstrCCType );

  HRESULT PrefixCheck (

  _bstr_t bstrCCNo,

  _bstr_t bstrCCType );……………………………………………….………….. 接口方法(对外)

  //

  // Raw methods provided by interface

  //

  virtual HRESULT __stdcall raw_ValidateCreditCard (

  BSTR bstrCCNo,

  BSTR bstrCCType,

  long * val ) = 0;

  virtual HRESULT __stdcall raw_LuhnCheck (

  BSTR bstrCCNo,

  BSTR bstrCCType ) = 0;

  virtual HRESULT __stdcall raw_LengthCheck (

  BSTR bstrCCNo,

  BSTR bstrCCType ) = 0;

  virtual HRESULT __stdcall raw_PrefixCheck (

  BSTR bstrCCNo,

  BSTR bstrCCType ) = 0;…………………………………………………..……. 接口方法(对内)

};

//

// Wrapper method implementations

//

#include "c:vctestvccomprojdebugValidateCreditCardServer.tli"………….. 类型库实现文件

} // namespace VALIDATECREDITCARDSERVERLib……………………………..……….. 名字空间

#pragma pack(pop)

 


参照COM组件端C:ValidateCreditCardServerValidateCreditCardServer.idl

 

ValidateCreditCardServer.idl清单


// ValidateCreditCardServer.idl : IDL source for ValidateCreditCardServer.dll

//

// This file will be processed by the MIDL tool to

// produce the type library (ValidateCreditCardServer.tlb) and marshalling code.

import "oaidl.idl";

import "ocidl.idl";

  [

  object,

  uuid(B1D1C73C-E340-4FDC-8734-92ECEC64DC4E),……………………………. IID部分

  dual,

  helpstring("IValidateCard Interface"),

  pointer_default(unique)

  ]

  interface IValidateCard : IDispatch

  {

  [id(1), helpstring("method ValidateCreditCard")] HRESULT ValidateCreditCard([in] BSTR bstrCCNo,[in]BSTR bstrCCType,[out,retval]long *val );

  [id(2), helpstring("method LuhnCheck")] HRESULT LuhnCheck([in] BSTR bstrCCNo,[in]BSTR bstrCCType);

  [id(3), helpstring("method LengthCheck")] HRESULT LengthCheck([in] BSTR bstrCCNo,[in]BSTR bstrCCType);

  [id(4), helpstring("method PrefixCheck")] HRESULT PrefixCheck([in] BSTR bstrCCNo,[in]BSTR bstrCCType);

  };

[

  uuid(B3404054-C33E-4931-B737-5783CEEFECdb),………………………………… LIBID部分

  version(1.0),

  helpstring("ValidateCreditCardServer 1.0 Type Library")

]

library VALIDATECREDITCARDSERVERLib

{

  importlib("stdole32.tlb");

  importlib("stdole2.tlb");

  [

  uuid(C79635D2-7B86-4B20-A83C-0565DCA54C3C),…………………….……CLSID部分

  helpstring("ValidateCard Class")

  ]

  coclass ValidateCard

  {

  [default] interface IValidateCard;

  };

};


小结:

Developing COM Components using VC-ATL(3)主要介绍了Visual C++与Visual Basic编写的组件的相互间的调用。在接下来一篇里将介绍双接口。

Developing COM Components using VC-ATL(3)完 


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/10752019/viewspace-963673/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
  • 博文量
    3982
  • 访问量
    7896812