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 can be of standard types like char, int, long, float etc. These are not allocated by COM server. Client passes the address of these variables and server puts the return value and then it returns to client. Client can use these values.

This is not same for the BSTR, Strings, arrays or other type of dynamically allocate buffers. Client passes the address of a pointer. COM server allocates the buffer and fills the return values. It then writes the address value to the parameter which client has provided. Now client can read this buffer and finally this buffer should be deallocated. Client has the control to this pointer so client can decide when to free up this buffer. It is the responsibility of the client to properly deallocate the buffer.

HRESULT hr;
BSTR* strSample; /* BSTR * or OLECHAR ** */
for (int i = 0; i < 5; i++)
{
  strSample = NULL;
  hr = ReturnBSTR(i, &strSample);
  if(hr == S_OK)
  { 
    wprintf(“String %d is %s\n”, i + 1, strSample);
    /* Now free this sting, else memory leak */
    SysFreeString (strSample);

  } else {
    wprintf(“ReturnBSTR return %x\n”, 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 Wed 30 Apr/2014 08:51:53(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.