Click here to Skip to main content
15,920,005 members
Home / Discussions / COM
   

COM

 
GeneralRe: Fire Event from outside the COM Method Pin
Koep30-May-02 23:51
Koep30-May-02 23:51 
GeneralRe: Fire Event from outside the COM Method Pin
Len Holgate31-May-02 0:01
Len Holgate31-May-02 0:01 
GeneralRe: Fire Event from outside the COM Method Pin
Koep31-May-02 1:00
Koep31-May-02 1:00 
GeneralRe: Fire Event from outside the COM Method Pin
Len Holgate31-May-02 1:11
Len Holgate31-May-02 1:11 
GeneralSafeArray Pin
Sameer Maggon27-May-02 20:18
Sameer Maggon27-May-02 20:18 
GeneralRe: SafeArray Pin
Prem Kumar28-May-02 7:14
Prem Kumar28-May-02 7:14 
Generaluse IStream instead Pin
soptest28-May-02 9:53
soptest28-May-02 9:53 
GeneralRe: SafeArray Pin
Len Holgate30-May-02 21:54
Len Holgate30-May-02 21:54 
I do something similar (return binary data in a safe array) in my COM Mailslots article. The code in question is:

STDMETHODIMP CMailslotData::Read(VARIANT *ppResults)
{
   if (!ppResults)
   {
      return E_POINTER;
   }

   return CreateSafeArray(m_pData, m_length, ppResults); 
}

where m_pData points to the bytes of data and m_length is the number of bytes we have.
HRESULT CreateSafeArray(
   BYTE *pData,
   DWORD dataLength,
   VARIANT *ppResults)
{
   SAFEARRAYBOUND sab;
   sab.cElements = dataLength;
   sab.lLbound = 0;

   SAFEARRAY *pSa = SafeArrayCreateEx(VT_UI1, 1, &sab, 0);
   
   PVOID pvData;
   
   HRESULT hr = SafeArrayAccessData(pSa, &pvData);
   
   if (SUCCEEDED(hr))
   {
      ::CopyMemory(pvData, pData, dataLength);
   
      hr = ::SafeArrayUnaccessData(pSa);
   }

   if (SUCCEEDED(hr))
   {
      ::VariantInit(ppResults);
           
      (*ppResults).parray = pSa;
      (*ppResults).vt = VT_ARRAY | VT_UI1;
   }

   return hr;
}


Hope this helps.

Len Holgate
www.jetbyte.com
The right code, right now.
GeneralFire COM Event from MFC Class Pin
Koep27-May-02 4:59
Koep27-May-02 4:59 
GeneralRe: Fire COM Event from MFC Class Pin
Prem Kumar28-May-02 7:22
Prem Kumar28-May-02 7:22 
Generalserver to client calls Pin
26-May-02 23:08
suss26-May-02 23:08 
GeneralRe: server to client calls Pin
Prem Kumar28-May-02 7:20
Prem Kumar28-May-02 7:20 
GeneralVB Script - Can I sink events - Automation Pin
Sara Burns26-May-02 0:27
Sara Burns26-May-02 0:27 
GeneralRe: VB Script - Can I sink events - Automation Pin
CodeCrew27-May-02 15:45
CodeCrew27-May-02 15:45 
GeneralRe: VB Script - Can I sink events - Automation Pin
Ernest Laurentin14-Jun-02 7:44
Ernest Laurentin14-Jun-02 7:44 
QuestionHelp...floundering...BSTR? Pin
Member 9624-May-02 6:35
Member 9624-May-02 6:35 
AnswerRe: Help...floundering...BSTR? Pin
soptest24-May-02 7:19
soptest24-May-02 7:19 
GeneralRe: Help...floundering...BSTR? Pin
Member 9624-May-02 7:36
Member 9624-May-02 7:36 
GeneralRe: Help...floundering...BSTR? Pin
soptest24-May-02 9:14
soptest24-May-02 9:14 
GeneralRe: Help...floundering...BSTR? Pin
Member 9624-May-02 10:17
Member 9624-May-02 10:17 
GeneralRe: Help...floundering...BSTR? Pin
Jason Henderson24-May-02 18:51
Jason Henderson24-May-02 18:51 
AnswerRe: Help...floundering...BSTR? Pin
Mazdak25-May-02 20:59
Mazdak25-May-02 20:59 
Generalhelp bluetooth. Pin
23-May-02 9:14
suss23-May-02 9:14 
GeneralRe: help bluetooth. Pin
soptest23-May-02 9:14
soptest23-May-02 9:14 
GeneralRe: help bluetooth. Pin
David Wulff23-May-02 16:26
David Wulff23-May-02 16:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.