I have another question which got clotted over here:
but now I have a different more specific problem which affects the code from that thread. I thought it best to start a new thread so everyone could answer this better without adding anymore to that thread.
Problem: I cannot get the fFeatures of the safe array to equal 2194 (FADF_HAVEVARTYPE+FADF_VARIANT+FADF_STATIC+FADF_FIXEDSIZE). I need them to be initialized or start out that way because I have the below c++ code calling another com server (softhidreceiver.dll) which expects the equilivent of a vb6 or vbscript variant (go with vbscript variant first) and if it is not initialized this way it fails to pass the data on correctly. So far the code from the above thread hits queueinputreport but since fFeatures is initialized to 2176 instead of 2194 queueinputreport fails to pass the data onto queueindata later in the program and my code fails to work. Many thanks to parish for helping to get me going in that thread.
Just for reference this is the function in question:
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); SAFEARRAYBOUND rgsabound[1]; ZeroMemory(&rgsabound, sizeof(rgsabound)); rgsabound[0].lLbound = 0; rgsabound[0].cElements = 5; BYTE bSampe[5] = {0x00,inputreport[1],inputreport[2],0x00,0x00}; static VARIANT HUGEP pDescriptorData[5] = {bSampe[0],bSampe[1],bSampe[2],bSampe[3],bSampe[4],bSampe[5]}; //pDescriptorData->parray = SafeArrayCreateVector(VT_VARIANT, 0, 5); SAFEARRAY *psaValues = NULL; HRESULT hr = SafeArrayAllocDescriptor(1, &psaValues); // create a SAFEARRAY structure of the object psaValues->cbElements = sizeof (pDescriptorData[0]); psaValues->rgsabound[0].cElements = 5; psaValues->rgsabound[0].lLbound = 0; psaValues->pvData = pDescriptorData; psaValues->fFeatures = FADF_FIXEDSIZE|FADF_AUTO; ///SafeArrayCreate(VT_VARIANT, 1,rgsabound); //SAFEARRAY * psaValues; // psaValues = SafeArrayCreateVector(VT_VARIANT, 0, 5); //psaValues->fFeatures = FADF_VARIANT + FADF_HAVEVARTYPE + FADF_FIXEDSIZE + FADF_STATIC; MessageBox(NULL,L"safe array created with static properties" ,NULL,NULL); SafeArrayLock(psaValues); // Step through the SAFEARRAY and populate each variant with a Byte value // SafeArrayAccessData( psaValues, (void HUGEP**)&pDescriptorData); //for( LONG i = 0; i <= 4; ++i ) // { //VariantInit(&pDescriptorData[i]); // VariantClear(&pDescriptorData[i]); //pDescriptorData[i].vt = VT_UI1; // pDescriptorData[i].bVal = bSampe[i]; // SafeArrayPutElement(psaValues,&i,&pDescriptorData); // _TCHAR szBuffer2[100]; // _stprintf_s(szBuffer2, _T("%i"), psaValues->pvData); //MessageBox(NULL,szBuffer2,L"data written to safe array",NULL); // } //10368 <-current fFeatures with above code. need 2194. MessageBox(NULL,L"data written to variant" ,NULL,NULL); SafeArrayUnlock(psaValues); if (psaValues == NULL) { return E_OUTOFMEMORY; } //psaValues->fFeatures = FADF_HAVEVARTYPE+FADF_VARIANT+FADF_STATIC+FADF_FIXEDSIZE; //psaValues->fFeatures = 2194; piSoftHidDevice1[devindex]->QueueInputReport(psaValues,10); piSoftHidDevice1[devindex]->StartProcessing(); //piSoftHidDevice1[devindex]->StopProcessing(); //SafeArrayUnaccessData(psaValues); return S_OK; //Exit: //SafeArrayUnaccessData(test); }
It calls softhidreceiver.dll's queueinputreport. But the function above in turn is called from vb.net.
Once you eliminate the impossible, whatever remains, no matter how improbable, must be the truth. - "Sherlock holmes" "speak softly and carry a big stick" - theodore roosevelt. Fear leads to anger, anger leads to hate, hate leads to suffering - Yoda. Blog - http://www.computerprofessions.co.nr