Click here to Skip to main content
15,849,182 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionBitwise operation for mod operation Pin
econy31-Mar-14 5:23
econy31-Mar-14 5:23 
AnswerRe: Bitwise operation for mod operation Pin
Richard MacCutchan31-Mar-14 22:38
mveRichard MacCutchan31-Mar-14 22:38 
AnswerRe: Bitwise operation for mod operation Pin
CPallini1-Apr-14 0:37
mveCPallini1-Apr-14 0:37 
QuestionDATABASE PROBLEM Pin
Fawaz Ajani31-Mar-14 2:01
Fawaz Ajani31-Mar-14 2:01 
AnswerRe: DATABASE PROBLEM Pin
Freak3031-Mar-14 5:42
Freak3031-Mar-14 5:42 
AnswerRe: DATABASE PROBLEM Pin
SujayG2-Apr-14 1:21
SujayG2-Apr-14 1:21 
QuestionRe: DATABASE PROBLEM Pin
David Crow2-Apr-14 18:27
David Crow2-Apr-14 18:27 
QuestionHow to use ReadFile API Read HID Device synchronous Pin
cedricvictor30-Mar-14 7:32
cedricvictor30-Mar-14 7:32 
Dear all:

I use ReadFile api to read HID device synchronous.

My code show as below:
C++
char preUsedSize = 0;
char curUsedSize = 0;

while(1)
{
    opening_HANDLE = TestHid.ReturnHandle();
    BOOL bGot = FALSE;
    Data64_t aData64;
    DWORD dwBytes = 0;
			

    BOOL bSus = ::ReadFile(opening_HANDLE, aData64.raw,    
                            sizeof(aData64), &dwBytes, NULL);
			
    if( bSus )
    {
        PTOUCH_REPORT inputData = (PTOUCH_REPORT)aData64.raw;
			
        curUsedSize = inputData->actualCnt;
	
        if(curUsedSize > preUsedSize)
	{
            for(int i = 0; i<(curUsedSize - preUsedSize);i++)
            {		      
                Beep(0x7fff, 500);
	    }					
       	}
	preUsedSize = curUsedSize;
					
        bGot = TRUE;		
    }
    else
    {
        CloseHandle(opening_HANDLE);       
    }
   
    if(!bGot)
    {				
     Sleep(500);
    }
}


My question is how do I clean preUsedSize and curUsedSize to 0,
If I did not get any data from my device(not get data failed)?

The FALSE of bSus means I get data from HID device fail, not no data income.


Thanks for your help, Victor.
AnswerRe: How to use ReadFile API Read HID Device synchronous Pin
Richard Andrew x6431-Mar-14 11:13
professionalRichard Andrew x6431-Mar-14 11:13 
AnswerRe: How to use ReadFile API Read HID Device synchronous Pin
Heng Xiangzhong9-Apr-14 0:31
Heng Xiangzhong9-Apr-14 0:31 
Question#imports for MS Office2013 Pin
Bryan Anslow28-Mar-14 11:08
Bryan Anslow28-Mar-14 11:08 
AnswerRe: #imports for MS Office2013 Pin
SujayG1-Apr-14 23:26
SujayG1-Apr-14 23:26 
GeneralRe: #imports for MS Office2013 Pin
Bryan Anslow2-Apr-14 5:23
Bryan Anslow2-Apr-14 5:23 
GeneralRe: #imports for MS Office2013 Pin
SujayG3-Apr-14 2:04
SujayG3-Apr-14 2:04 
GeneralRe: #imports for MS Office2013 Pin
Bryan Anslow3-Apr-14 6:02
Bryan Anslow3-Apr-14 6:02 
GeneralRe: #imports for MS Office2013 Pin
SujayG4-Apr-14 19:43
SujayG4-Apr-14 19:43 
QuestionAn algorithm question Pin
econy26-Mar-14 16:53
econy26-Mar-14 16:53 
AnswerRe: An algorithm question Pin
Richard MacCutchan27-Mar-14 0:08
mveRichard MacCutchan27-Mar-14 0:08 
GeneralRe: An algorithm question Pin
econy27-Mar-14 4:38
econy27-Mar-14 4:38 
AnswerRe: An algorithm question Pin
CPallini28-Mar-14 11:31
mveCPallini28-Mar-14 11:31 
GeneralRe: An algorithm question Pin
econy31-Mar-14 5:12
econy31-Mar-14 5:12 
GeneralRe: An algorithm question Pin
chaau1-Apr-14 18:17
chaau1-Apr-14 18:17 
AnswerRe: An algorithm question Pin
Stefan_Lang3-Apr-14 4:29
Stefan_Lang3-Apr-14 4:29 
QuestionReceive UDP packet from multiple default gateway Pin
Shanky426-Mar-14 6:18
Shanky426-Mar-14 6:18 
QuestionRe: Receive UDP packet from multiple default gateway Pin
Richard MacCutchan26-Mar-14 6:32
mveRichard MacCutchan26-Mar-14 6:32 

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.