I have the following code that I am trying to get working in c++:
STDMETHODIMP CMMEmulator::sendinputreport(BYTE inputreport[5]) { // Step through the SAFEARRAY and populate each variant with a Byte value //INT descSize2 = sizeof(inputreport); // SAFEARRAYBOUND rgsabound[1]; //need 2194 instead of 2176 or FADF_STATIC and FADF_FIXEDSIZE included also. //VARIANT HUGEP* pDescriptorData = NULL; // VARIANT pDescriptorData[5]; //ZeroMemory(rgsabound,sizeof(rgsabound)); // rgsabound[0].lLbound = 0; //rgsabound[0].cElements = 5; //SAFEARRAY *psaValues = SafeArrayCreateVector(VT_VARIANT|VT_ARRAY, 0,5); //BYTE bSampe[5] = {0x01,0x02,0x03,0x04,0x04}; CComSafeArray<VARIANT,VT_UI1> savt; //LONG j[5]; LONG length = 4; //SafeArrayLock(psaValues); for(LONG i = 0; i <= length; ++i) { //j[i] = i; MessageBox(NULL,L"inputreport assigned to variable",NULL,NULL); //pDescriptorData[i].vt = VT_UI1; //pDescriptorData[i].bVal = inputreport[i]; //SafeArrayPutElement(psaValues,&i,&pDescriptorData[i]); // VariantClear(&pDescriptorData[i]); savt.Add(CComVariant(inputreport[i])); } MessageBox(NULL,L"data is successfully assigned to safearray",L"correct data format",NULL); piSoftHidDevice1[devindex]->QueueInputReport(savt,8); piSoftHidDevice1[devindex]->StartProcessing(); piSoftHidDevice1[devindex]->StopProcessing(); return S_OK; //Exit: //SafeArrayUnaccessData(test); return hr; }
This code is supposed to pass a safearray of variants containing an array of bytes to a subroutine (each variant I think contains an array of bytes but it could be multiple variants each containing one byte value). However, I cannot get it working correctly. Could I be passing it wrong? If I set fFeatures it does not help either. How do I get the fFeatures to equal 2194 (0x892 in hex)? I think this maybe the reason it does not get passed to the c/c++ subroutine that sends my devices input report or emulates input. Basically, I need to fill the safe array with byte values but the outer layer of the safe array is variant.
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