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

amyz發表於2007-08-17
Developing COM Components using VC-ATL(3-7) (轉)[@more@]:namespace prefix = o ns = "urn:schemas--com::office" />

最後讓我們分析一下C:VCTestVCComProjDeValidateCreditCardServer.tlh作為Develo Components using VC-ATL(3)的結尾吧。

ValidateCreditCardServer.tlh清單

 


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

//

// c:vctestvccomprojdebugValidateCreditCardServer.tlh

//

// C++ equivalent of 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 provd 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";

  [

  ,

  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-5783CEEFEC),………………………………… 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++與編寫的元件的相互間的。在接下來一篇裡將介紹雙介面。

Developing COM Components using VC-ATL(3)完 


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10752019/viewspace-963673/,如需轉載,請註明出處,否則將追究法律責任。

相關文章