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

OUT parameters

[OUT] parameters are always returned as reference and thus they are pointers. Caller should provide the address of the variable and called function should write the value of the variable in the address.

HRESULT ReturnChar(char *pchVal);
HRESULT ReturnInt(int *pnVal);
HRESULT ReturnLong(long *plVal);
HRESULT ReturnFloat(float *pfVal);
HRESULT ReturnDouple(int *pdVal);

<type> variable;

hr = ReturnType(&variable);
if(hr == S_OK)
  cout << "Returned value is << variable;

} else {
  cout << "error: " << hr;

dynamic OUT parameters

There could be string and malloc buffer or dynamic array for out variable. In those cases parameter has to be pointer to a pointer. Caller has to pass the address of the pointer variable. Calle or function should allocate a pointer or array buffer and this address value should be written to the caller provided address.

void ReturnString(char **pdVal);
void ReturnPointer(void **pvVal);
void ReturnBSTR(BSTR *pvVal);

BSTR* varString; /* BSTR * or OLECHAR ** */

hr = ReturnType(&varString);
if(hr == S_OK)
  cout << "Returned value is << varString;
  /* Now free this sting, else memory leak */
  SysFreeString (varString);
  cout << "error: " << hr;

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 01:08:46(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.


Your message goes here:

My Post:*
Secutiry Code: ******  *
Preview this compose before posting this in discussion forum.
  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.