Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 12th, 2012  |  syntax: None  |  size: 0.54 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. return array from com object
  2. [id(1)] HRESULT GetAlarms([out,retval] SAFEARRAY(VARIANT)* pAlarms);
  3.        
  4. STDMETHODIMP CMyClass::GetAlarms(SAFEARRAY** pAlarms)
  5. {
  6.     CComSafeArray<VARIANT> alarms(3);
  7.     CComVariant value;
  8.  
  9.     value = L"First Alarm";
  10.     alarms.SetAt(0, value);
  11.  
  12.     value = L"Second Alarm";
  13.     alarms.SetAt(1, value);
  14.  
  15.     value = L"Third Alarm";
  16.     alarms.SetAt(2, value);
  17.  
  18.     *pAlarms = alarms.Detach();
  19.  
  20.     return S_OK;
  21. }
  22.        
  23. Set obj = CreateObject("MyLib.MyClass")
  24. a = obj.GetAlarms
  25. For i = 0 To UBound(a)
  26.    MsgBox a(i)
  27. Next