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

Array is a chunk of data block located in heap, or data area of the application. The starting address of array can be passed in functions as pointer. Programming languages like C/C++/VB uses pointer to pass arrays. Array can be passed to the functions located in same application code or to an external dynamic link library. Function of external DLL also maps to application address space so the array can be accessed with out any issue.

DCOM works in a different way. There COM client and server are not in same process space. Marshalling process copies array block while functions are executed and parameters are exchanged. Now Marshalling process of DCOM should know the size of the array block so that it can copy that amount of data to LPC or RPC buffer. IDL uses one parameter to indicate the array size and size_is(parameter) is used in the attribute of the array. Passing a raw block array in COMaNow this data block is located in same address space size of the

IDL size_is

  helpstring("IDaysArray Interface"),
interface IDaysArray : IDispatch
  [id(1), helpstring("method GetDaysString using size_is()")]
  HRESULT GetDaysString([in] long cDays, [out, size_is(cDays)] BSTR * pDays);


Array in COM server

STDMETHODIMP CDaysArray::GetDaysString(long cDays, BSTR *pDays)

  unsigned short *days[5] = {
  long nLbound;
  BSTR strDay;
  for(nLbound = 0; nLbound < cDays ; nLbound++)
    strDay = SysAllocString(days[nLbound]);
    pDays[nLbound] = strDay;
  return S_OK;

Array in COM client

#import "CWeekDaysEnumXXX.dll"

int main(int argc, char* argv[])
  BSTR Days[5];
  CWEEKDAYSENUMXXXLib::IDaysArrayPtr  DaysArrayPtr;
  hr = DaysArrayPtr.CreateInstance("CWeekDaysEnumXXX.DaysArray");
  if(hr != S_OK)
    wprintf(L"CreateInstance(\"CWeekDaysEnumXXX.DaysArray\") error %x\n",hr);
    return hr;
  hr = DaysArrayPtr->GetDaysString(5, Days);
  if(hr == S_OK)
    for (int i = 0; i < 5; i++)
      wprintf(L"Day %d : %s \n",i+1,Days[i]);
  } else {
    wprintf(L"GetDaysString error %x\n",hr);
  return 0;

Array in COM VB client

Option Explicit
Option Base 0

Private Sub Form_Load()
  Dim DaysArray As DaysArray
  Dim days(0 To 4) As String
  Dim i As Integer

  Set DaysArray = New CWEEKDAYSENUMXXXLib.DaysArray
  DaysArray.GetDaysString 5, days(0)
  For i = 0 To 4
    MsgBox days(i)
  Set DaysArray = Nothing
End Sub

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 00:25:55(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.