fFeatures需要等于2194?

时间:2014-02-28 00:01:45

标签: c++ windows device-driver variant

目前,我正努力在下面的c ++代码中使用变量的安全阵列。如你所见,我调用了QueueInputReport,其签名为(SAFEARRAY * psainputreport,UNIT timeoutduration):

    CComSafeArray<VARIANT> 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);

     //VariantInit(&pDescriptorData[i]);
        //pDescriptorData[i].vt = VT_UI1;
        //pDescriptorData[i].bVal = inputreport[i];
        //SafeArrayPutElement(psaValues,&i,&pDescriptorData[i]);
       //  VariantClear(&pDescriptorData[i]);

       savt.Add(CComVariant(inputreport[i]));  
    }

    //SafeArrayUnlock(psaValues);

MessageBox(NULL,L"data is successfully assigned to safearray",L"correct data format",NULL);
//FADF_STATIC+FADF_FIXEDSIZE+FADF_HAVEVARTYPE+FADF_VARIANT;
/* _TCHAR szBuffer2[100];
_stprintf_s(szBuffer2, _T("%i"),&psaValues->fFeatures);
MessageBox(NULL,L"safe array type",szBuffer2,NULL);*/

piSoftHidDevice1[devindex]->QueueInputReport(savt,8);
piSoftHidDevice1[devindex]->StartProcessing();
piSoftHidDevice1[devindex]->StopProcessing();

编辑:下面是我需要将数据传递给的queueinputreport的代码。

 STDMETHODIMP CHIDDevice::QueueInputReport( SAFEARRAY* psaInputReport, UINT timeoutDuration )
/*++
Routine Description: Queues additional input reports

Arguments:
IdleTimeout - used to set the value of the log level

Return value:
S_OK
--*/
{

VARIANT *  pArrayData  = NULL;
UINT               cbData      = 5;
LONG                lLBound     = 0;
LONG                lUBound     = 0;
HRESULT             hr          = S_OK;
HID_INPUT_REPORT    inputReport;
BOOLEAN             result      = TRUE;

// Initialize Structure
inputReport.timeout = timeoutDuration;
inputReport.cbInputReport = 0;
inputReport.pbInputReport = NULL;
    MessageBox(NULL,L"report initialized",L"initial report",NULL);
// Get SAFEARRAY size
IfFailHrGo(SafeArrayGetLBound(psaInputReport, 1, &lLBound));
IfFailHrGo(SafeArrayGetUBound(psaInputReport, 1, &lUBound));
IfFalseHrGo(lUBound > lLBound, E_UNEXPECTED);
cbData = lUBound - lLBound + 1;
//psaInputReport->fFeatures = 0x892;
//psaInputReport->fFeatures = 0x892;
inputReport.pbInputReport = (BYTE*)CoTaskMemAlloc( cbData * sizeof(BYTE) );
 _TCHAR szBuffer3[100];
_stprintf_s(szBuffer3, _T("%i"), &psaInputReport->fFeatures);
MessageBox(NULL,L"array content features",szBuffer3,NULL);
// If the memory Allocation fails, then fail and exit
if( inputReport.pbInputReport == NULL )
{
    hr = E_UNEXPECTED;
    goto Exit;
}
//void HUGEP** cast orginally
IfFailHrGo( SafeArrayAccessData( psaInputReport, 
                                 reinterpret_cast<void HUGEP**>(&pArrayData) ) );

// Step through the SAFEARRAY and populating only BYTE input report
// and bail out if the type is not correct
for( LONG i = 0; i <= lUBound; ++i )
{
    if (pArrayData[i].vt == VT_UI1)
    {

        inputReport.pbInputReport[i] = pArrayData[i].bVal;

    }
    else
    {
        hr = E_FAIL;
        goto Exit;
    }
}
  SafeArrayUnaccessData(psaInputReport);
inputReport.cbInputReport = cbData;
    //MessageBox(NULL,L"report being sent next",L"sent report",NULL);
// Add the report to the input queue (does a shallow copy so no need to free the array data)
result = m_InputReportQueue.insert( inputReport );

if (result == FALSE)
{
    MessageBox(NULL,L"failed to queue the input",NULL,NULL);
    hr = E_FAIL;
}
return hr;
Exit:
SafeArrayUnaccessData(psaInputReport);
if( FAILED(hr) )
{
    CoTaskMemFree(inputReport.pbInputReport);
}
return hr;
}

编辑:问题是我需要fFeatures等于2194,它目前是一个非常高的数字。我能做错什么?

在vbscript中,我有一些queueinputreport的工作代码:

........(此处列出的代码太多,但它代表我发送输入的设备(即设备#1,#2,#3)) 以下是有关IFe所讨论的fFeatures的更多信息: http://msdn.microsoft.com/en-us/library/cc237824.aspx

     Dim inputreport(5)
     inputreport(0) = CByte(0)
     inputreport(1) = CByte(100)
     inputreport(2) = CByte(100)
     inputreport(3) = CByte(0)
     inputreport(4) = Cbyte(0)
     pisofthiddevice1(i).QueueInputReport(inputreport, 8)

但是,当我尝试在C ++中复制它时,它不起作用。

0 个答案:

没有答案