Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. ATL / WTL / STL
  4. trouble with a safe array of variants

trouble with a safe array of variants

Scheduled Pinned Locked Moved ATL / WTL / STL
c++comdata-structuresquestionlounge
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jeffery c
    wrote on last edited by
    #1

    I have a safe array of variants I have been working on getting working in c++. I need to pass a safearray of variants with this flags in fFeatures set by default: FADF_FIXEDSIZE, FADF_STATIC, FADF_HAVEVARTYPE and FADF_VARIANT. Trouble is I have an ATL com dll project (mouse emulator) that wraps another ATL com dll called softhidreceiver. When I called softhidreceiver I need to pass a safe array of variants but Iam having trouble doing so. Here is an msdn forum post that never got solved but grew so large I just started a new post. http://social.msdn.microsoft.com/Forums/vstudio/en-US/a54fdef1-6479-41dc-8662-4c615d1dab9e/invalid-safearray-of-variants#be1b5734-9a80-439e-a3dd-32f48d24ab84[^] Anyone knowledge with safearray of variants? I have not choice in the matter unless someone has a better idea of passing values to queueinputreport? Heres my current code though so far:

    STDMETHODIMP CMMEmulator::sendinputreport(unsigned char inputreport[5], int length)
    {

    \_TCHAR szBuffer\[100\];
    \_stprintf\_s(szBuffer, \_T("%i"), inputreport\[1\]);
    MessageBox(NULL,L"value of second byte input report",szBuffer,NULL);
    
    BYTE bSampe\[5\] = {0x00,inputreport\[1\],inputreport\[2\],0x00,0x00};
    HRESULT        hr            = S\_OK;
    SAFEARRAY     \*psaData       = NULL;
    VARIANT HUGEP\* pVarArrayData = NULL;
     SAFEARRAYBOUND bound;
    bound.cElements = 5;
    bound.lLbound = 0;
    

    psaData = SafeArrayCreateVector(VT_VARIANT,0,5);

    hr = SafeArrayAccessData(psaData, (void HUGEP**)&pVarArrayData);
    if (SUCCEEDED(hr))
    {
    for (long i = 0; i < 5; i++)
    {
    VariantInit(&pVarArrayData[i]);
    pVarArrayData[i].vt = VT_UI1;
    pVarArrayData[i].bVal = static_cast<byte>(bSampe[i]);
    // SafeArrayPutElement(psaData,&i,&pVarArrayData);
    }
    hr = SafeArrayUnaccessData(psaData);
    if (SUCCEEDED(hr))
    {
    piSoftHidDevice1[devindex]->QueueInputReport(psaData,10);
    piSoftHidDevice1[devindex]->StartProcessing();
    }
    }
    SafeArrayDestroy(psaData);

    //piSoftHidDevice1\[devindex\]->StopProcessing();
    return S\_OK;
    //Exit:
    

    }

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups