EQuestionAnswers.com Computer/Electronics Questions and Answers
C, C++, VC++, COM/DCOM, DLL and more
#Login #Sign up  Facebook Twitter TGoogle+
 

#Previous question #Index of COM/DCOM Questions #Next question

Methods and Properties

An interface can have three types of methods 1) Property Get methods, 2) Property Put Methods, 3) Class Functions. All of these methods have some common syntax -

interface I<Interface Name>: IDispatch
{
  [<property type>, id(<index>), helpstring(< >)]
  HRESULT <Method Name>([<in/out/retval>] <data type> <Argument name>, ..);
}

Method attributes

A method has some attributes which are enclosed in brackets [] and should be placed before the method prototype.

  • Property Method - Property GET or PUT are the options and denoted as propget and propput. This field is not applicable for normal functions
  • id() - Method identity is the index number starting from one.
  • helpstring - A help description string for the method for the developer

Method prototype

Method prototype is similar to C/C++ function prototype with additional fields.

  • Return Type - Return type of the method. HRESULT should be the return type for all methods.
  • Method Name - Like C/C++ function name with a meaningful name
  • Arguments types - Argument types are [in] input, [out] output, [in,out] both input & output and [retval] return.
  • Arguments data types - char, short, long, bstr_t etc
  • Arguments name - Like C/C++ function arguments with a meaningful names

Property Get methods

COM/DCOM class can have member variables or properties. The design does not allow client to access public members. All has to be through functions and methods. Property Get methods are functions to return the value of a specific property or member variable.

  • Property Method -[propget] attribute should used.
  • Arguments types -[out,retval] is used
  • Arguments data types - - depending on the type of the property and should be pointer or as passed as reference
[propget, id(1), helpstring("Operand1 of calculator")]
HRESULT Operand1([out, retval] long *pVal);

Property Put methods

Property Put methods are functions to set the value of a specific property or member variable.

  • Property/Method -[propput] attribute should used.
  • Arguments types - method with a single input argument denoted as [in]
  • Arguments data types - depending on the type of the property
[propput, id(1), helpstring("Operand1 of calculator")]
HRESULT Operand1([in] long newVal);

Class Functions/methods

Interface methods does not have propget/propput and it can have multiple input or output arguments and or one return arguments.

  • Property/Method -attribute is not applicable.
  • Arguments types Argument types are [in] input, [out] output, [in,out] both input & output and [retval] return.
  • Arguments data types - Depending on design
[id(3), helpstring(“example method")]
HRESULT DoOperation();

[id(3), helpstring(“example method")]
HRESULT DoOperation([in] char operation);

[id(3), helpstring(“example method")]
HRESULT DoOperation([in] char operation, [in,out] short *pVal);

[id(3), helpstring(“example method")]
HRESULT DoOperation([in] char operation, [out,retval] short *pVal);

You have viewed 1 page out of 66. Your COM/DCOM learning is 0.00% complete. Login to check your learning progress.

 Vote 0

Similar topics related to this section

# COM DCOM Interview Questions and Answers :: ALL Interview .com
# COM DCOM - COM DCOM Interview Questions
# COM interview questions | TechInterviews
# COM Interview Questions - CodeProject
# Com Dcom Interview Questions - Com and Dcom in Asp Net
# ATL Interview Questions and Answers :: ALL Interview .com
# ActiveX Interview Questions and Answers :: ALL Interview .com

* #1 webmaster Mon 28 Apr/2014 19:38:29(GMT)  Like 0 Unlike 0

Dear Users,

We are pleased to inform you that a forum/blog has been incorporated with www.mybestnotes.co.in. You are welcomed to add your comments, requests, codes, solutions and feedback to it. Please login(if already a member) or signup(for free) to avail to this facility.

Regards,
Webmaster

Your message goes here:

Name:Guest
Email:anonymous@unknown.com
My Post:*
Secutiry Code: ******  *
Preview this compose before posting this in discussion forum.
 
Note:
  1. Use [Sxx] code to show smiles. Example [S02]
  2. Use [URL ], example [URL http://www.google.com/]
  3. To display code or un formatted text use [CODE] [/CODE]. Example: [CODE] printf("Hello world"); [/CODE]
 [S01]   [S02]   [S03]   [S04]   [S05]   [S06]   [S07]   [S08] 
 [S09]   [S10]   [S11]   [S12]   [S13]   [S14]   [S15]   [S16] 
 [S17]   [S18]   [S19]   [S20]   [S21]   [S22]   [S23]   [S24] 

Note: Only members are allowed, * fields are mandatory.