亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? commcode.c

?? The TapiComm sample uses both the Telephony API and the Win32 Communications API to demonstrate one
?? C
?? 第 1 頁 / 共 3 頁
字號:
            }

            default:    // This case should never occur.
            {
                OutputDebugPrintf("Unexpected Wait return value '%lx'",
                    dwHandleSignaled);
                PostHangupCall();
                goto EndReadThread;
            }
        } // End of switch(dwHandleSignaled).

    } // End of while(TRUE) loop.


    // Time to clean up Read Thread.
  EndReadThread:

    OutputDebugString("Read thread shutting down\n");
    PurgeComm(g_hCommFile, PURGE_RXABORT | PURGE_RXCLEAR);
    CloseHandle(overlappedRead.hEvent);
    CloseHandle(overlappedCommEvent.hEvent);
    g_dwReadThreadID = 0;
    CloseHandle(g_hReadThread);
    g_hReadThread = 0;
    return 0;
}


//
//  FUNCTION: SetupReadEvent(LPOVERLAPPED, LPSTR, DWORD, LPDWORD)
//
//  PURPOSE: Sets up an overlapped ReadFile
//
//  PARAMETERS:
//    lpOverlappedRead      - address of overlapped structure to use.
//    lpszInputBuffer       - Buffer to place incoming bytes.
//    dwSizeofBuffer        - size of lpszInputBuffer.
//    lpnNumberOfBytesRead  - address of DWORD to place the number of read bytes.
//
//  RETURN VALUE:
//    TRUE if able to successfully setup the ReadFile.  FALSE if there
//    was a failure setting up or if the CloseEvent object was signaled.
//
//  COMMENTS:
//
//    This function is a helper function for the Read Thread.  This
//    function sets up the overlapped ReadFile so that it can later
//    be waited on (or more appropriatly, so the event in the overlapped
//    structure can be waited upon).  If there is data waiting, it is
//    handled and the next ReadFile is initiated.
//    Another possible reason for returning FALSE is if the comm port
//    is closed by the service provider.
//    
//
//

BOOL SetupReadEvent(LPOVERLAPPED lpOverlappedRead,
    LPSTR lpszInputBuffer, DWORD dwSizeofBuffer,
    LPDWORD lpnNumberOfBytesRead)
{
    DWORD dwLastError;

  StartSetupReadEvent:

    // Make sure the CloseEvent hasn't been signaled yet.
    // Check is needed because this function is potentially recursive.
    if (WAIT_TIMEOUT != WaitForSingleObject(g_hCloseEvent,0))
        return FALSE;
    
    // Start the overlapped ReadFile.
    if (ReadFile(g_hCommFile, 
            lpszInputBuffer, dwSizeofBuffer,
            lpnNumberOfBytesRead, lpOverlappedRead))
    {
        // This would only happen if there was data waiting to be read.

        OutputDebugString("Data waiting for ReadFile.\n");
        
        // Handle the data.
        if (!HandleReadData(lpszInputBuffer, *lpnNumberOfBytesRead))
        {
            return FALSE;
        }

        // Start waiting for more data.
        goto StartSetupReadEvent;
    }

    // ReadFile failed.  Expected because of overlapped I/O.
    dwLastError = GetLastError();


    // LastError was ERROR_IO_PENDING, as expected.
    if (dwLastError == ERROR_IO_PENDING)
    {
        OutputDebugString("Waiting for data from comm connection.\n");
        return TRUE;
    }

    // Its possible for this error to occur if the 
    // service provider has closed the port.  Time to end.
    if (dwLastError == ERROR_INVALID_HANDLE)
    {
        OutputDebugString("ERROR_INVALID_HANDLE, "
            "Likely that the Service Provider has closed the port.\n");
        return FALSE;
    }

    // Unexpected error. No idea what could cause this to happen.
    OutputDebugLastError(dwLastError,"Unexpected ReadFile error: ");
    
    PostHangupCall();
    return FALSE;
}
 
 
//
//  FUNCTION: HandleReadEvent(LPOVERLAPPED, LPSTR, DWORD, LPDWORD)
//
//  PURPOSE: Retrieves and handles data when there is data ready.
//
//  PARAMETERS:
//    lpOverlappedRead      - address of overlapped structure to use.
//    lpszInputBuffer       - Buffer to place incoming bytes.
//    dwSizeofBuffer        - size of lpszInputBuffer.
//    lpnNumberOfBytesRead  - address of DWORD to place the number of read bytes.
//
//  RETURN VALUE:
//    TRUE if able to successfully retrieve and handle the available data.
//    FALSE if unable to retrieve or handle the data.
//
//  COMMENTS:
//
//    This function is another helper function for the Read Thread.  This
//    is the function that is called when there is data available after
//    an overlapped ReadFile has been setup.  It retrieves the data and
//    handles it.
//
//

BOOL HandleReadEvent(LPOVERLAPPED lpOverlappedRead,
    LPSTR lpszInputBuffer, DWORD dwSizeofBuffer,
    LPDWORD lpnNumberOfBytesRead)
{
    DWORD dwLastError;

    if (GetOverlappedResult(g_hCommFile,
            lpOverlappedRead, lpnNumberOfBytesRead, FALSE))
    {
        return HandleReadData(lpszInputBuffer, *lpnNumberOfBytesRead);
    }

    // Error in GetOverlappedResult; handle it.

    dwLastError = GetLastError();

    // Its possible for this error to occur if the 
    // service provider has closed the port.  Time to end.
    if (dwLastError == ERROR_INVALID_HANDLE)
    {
        OutputDebugString("ERROR_INVALID_HANDLE, "
            "Likely that the Service Provider has closed the port.\n");
        return FALSE;
    }

    OutputDebugLastError(dwLastError, 
        "Unexpected GetOverlappedResult Read Error: ");

    PostHangupCall();
    return FALSE;
}


//
//  FUNCTION: HandleReadData(LPCSTR, DWORD)
//
//  PURPOSE: Deals with data after its been read from the comm file.
//
//  PARAMETERS:
//    lpszInputBuffer  - Buffer to place incoming bytes.
//    dwSizeofBuffer   - size of lpszInputBuffer.
//
//  RETURN VALUE:
//    TRUE if able to successfully handle the data.
//    FALSE if unable to allocate memory or handle the data.
//
//  COMMENTS:
//
//    This function is yet another helper function for the Read Thread.
//    It LocalAlloc()s a buffer, copies the new data to this buffer and
//    calls PostWriteToDisplayCtl to let the EditCtls module deal with
//    the data.  Its assumed that PostWriteToDisplayCtl posts the message
//    rather than dealing with it right away so that the Read Thread
//    is free to get right back to waiting for data.  Its also assumed
//    that the EditCtls module is responsible for LocalFree()ing the
//    pointer that is passed on.
//
//

BOOL HandleReadData(LPCSTR lpszInputBuffer, DWORD dwSizeofBuffer)
{
    // If we got data and didn't just time out empty...
    if (dwSizeofBuffer)
    {
        LPSTR lpszPostedBytes;

        // Do something with the bytes read.
        OutputDebugString("Got something from Comm port!!!\n");

        lpszPostedBytes = LocalAlloc(LPTR,dwSizeofBuffer+1);
        if (lpszPostedBytes == NULL)
        {
            OutputDebugLastError(GetLastError(), "LocalAlloc: ");
            return FALSE;
        }

        memcpy(lpszPostedBytes, lpszInputBuffer, dwSizeofBuffer);
        lpszPostedBytes[dwSizeofBuffer] = '\0';

        return PostWriteToDisplayCtl(lpszPostedBytes, dwSizeofBuffer);
    }

}


//
//  FUNCTION: SetupCommEvent(LPOVERLAPPED, LPDWORD)
//
//  PURPOSE: Sets up the overlapped WaitCommEvent call.
//
//  PARAMETERS:
//    lpOverlappedCommEvent - Pointer to the overlapped structure to use.
//    lpfdwEvtMask          - Pointer to DWORD to received Event data.
//
//  RETURN VALUE:
//    TRUE if able to successfully setup the WaitCommEvent.
//    FALSE if unable to setup WaitCommEvent, unable to handle
//    an existing outstanding event or if the CloseEvent has been signaled.
//
//  COMMENTS:
//
//    This function is a helper function for the Read Thread that sets up
//    the WaitCommEvent so we can deal with comm events (like Comm errors)
//    if they occur.
//
//

BOOL SetupCommEvent(LPOVERLAPPED lpOverlappedCommEvent,
    LPDWORD lpfdwEvtMask)
{
    DWORD dwLastError;

  StartSetupCommEvent:

    // Make sure the CloseEvent hasn't been signaled yet.
    // Check is needed because this function is potentially recursive.
    if (WAIT_TIMEOUT != WaitForSingleObject(g_hCloseEvent,0))
        return FALSE;

    // Start waiting for Comm Errors.
    if (WaitCommEvent(g_hCommFile, lpfdwEvtMask, lpOverlappedCommEvent))
    {
        // This could happen if there was an error waiting on the
        // comm port.  Lets try and handle it.

        OutputDebugString("Event (Error) waiting before WaitCommEvent.\n");

        if (!HandleCommEvent(NULL, lpfdwEvtMask, FALSE))
            return FALSE;

        // What could cause infinite recursion at this point?
        goto StartSetupCommEvent;
    }

    // We expect ERROR_IO_PENDING returned from WaitCommEvent
    // because we are waiting with an overlapped structure.

    dwLastError = GetLastError();

    // LastError was ERROR_IO_PENDING, as expected.
    if (dwLastError == ERROR_IO_PENDING)
    {
        OutputDebugString("Waiting for a CommEvent (Error) to occur.\n");
        return TRUE;
    }

    // Its possible for this error to occur if the 
    // service provider has closed the port.  Time to end.
    if (dwLastError == ERROR_INVALID_HANDLE)
    {
        OutputDebugString("ERROR_INVALID_HANDLE, "
            "Likely that the Service Provider has closed the port.\n");
        return FALSE;
    }

    // Unexpected error. No idea what could cause this to happen.
    OutputDebugLastError(dwLastError, "Unexpected WaitCommEvent error: ");
    return FALSE;
}


//
//  FUNCTION: HandleCommEvent(LPOVERLAPPED, LPDWORD, BOOL)
//
//  PURPOSE: Handle an outstanding Comm Event.
//
//  PARAMETERS:
//    lpOverlappedCommEvent - Pointer to the overlapped structure to use.
//    lpfdwEvtMask          - Pointer to DWORD to received Event data.
//     fRetrieveEvent       - Flag to signal if the event needs to be
//                            retrieved, or has already been retrieved.
//
//  RETURN VALUE:
//    TRUE if able to handle a Comm Event.
//    FALSE if unable to setup WaitCommEvent, unable to handle
//    an existing outstanding event or if the CloseEvent has been signaled.
//
//  COMMENTS:
//
//    This function is a helper function for the Read Thread that (if
//    fRetrieveEvent == TRUE) retrieves an outstanding CommEvent and
//    deals with it.  The only event that should occur is an EV_ERR event,
//    signalling that there has been an error on the comm port.
//
//    Normally, comm errors would not be put into the normal data stream
//    as this sample is demonstrating.  Putting it in a status bar would
//    be more appropriate for a real application.
//
//

BOOL HandleCommEvent(LPOVERLAPPED lpOverlappedCommEvent, 
    LPDWORD lpfdwEvtMask, BOOL fRetrieveEvent)
{
    DWORD dwDummy;
    LPSTR lpszOutput;
    char szError[128] = "";
    DWORD dwErrors;
    DWORD nOutput;
    DWORD dwLastError;


    lpszOutput = LocalAlloc(LPTR,256);
    if (lpszOutput == NULL)
    {
        OutputDebugLastError(GetLastError(), "LocalAlloc: ");
        return FALSE;
    }

    // If this fails, it could be because the file was closed (and I/O is
    // finished) or because the overlapped I/O is still in progress.  In
    // either case (or any others) its a bug and return FALSE.
    if (fRetrieveEvent)
        if (!GetOverlappedResult(g_hCommFile, 
                lpOverlappedCommEvent, &dwDummy, FALSE))
        {
            dwLastError = GetLastError();

            // Its possible for this error to occur if the 
            // service provider has closed the port.  Time to end.
            if (dwLastError == ERROR_INVALID_HANDLE)
            {
                OutputDebugString("ERROR_INVALID_HANDLE, "
                    "Likely that the Service Provider has closed the port.\n");
                return FALSE;
            }

            OutputDebugLastError(dwLastError,
                "Unexpected GetOverlappedResult for WaitCommEvent: ");
            return FALSE;
        }

    // Was the event an error?
    if (*lpfdwEvtMask & EV_ERR)
    {
        // Which error was it?
        if (!ClearCommError(g_hCommFile, &dwErrors, NULL))
        {
            dwLastError = GetLastError();

            // Its possible for this error to occur if the 
            // service provider has closed the port.  Time to end.
            if (dwLastError == ERROR_INVALID_HANDLE)
            {
                OutputDebugString("ERROR_INVALID_HANDLE, "
                    "Likely that the Service Provider has closed the port.\n");
                return FALSE;
            }

            OutputDebugLastError(GetLastError(),"ClearCommError: ");
            return FALSE;
        }

        // Its possible that multiple errors occured and were handled
        // in the last ClearCommError.  Because all errors were signaled
        // individually, but cleared all at once, pending comm events 
        // can yield EV_ERR while dwErrors equals 0.  Ignore this event.
        if (dwErrors == 0)
        {
            strcat(szError, "NULL Error");
        }
       
        if (dwErrors & CE_FRAME)
        {
            if (szError[0])
                strcat(szError," and ");

            strcat(szError,"CE_FRAME");
        }

        if (dwErrors & CE_OVERRUN)
        {
            if (szError[0])
                strcat(szError," and ");

            strcat(szError,"CE_OVERRUN");
        }

        if (dwErrors & CE_RXPARITY)
        {
            if (szError[0])
                strcat(szError," and ");

            strcat(szError,"CE_RXPARITY");
        }

        if (dwErrors & ~ (CE_FRAME | CE_OVERRUN | CE_RXPARITY))
        {
            if (szError[0])
                strcat(szError," and ");

            strcat(szError,"EV_ERR Unknown EvtMask");
        }


        nOutput = wsprintf(lpszOutput,
            "Comm Event: '%s', EvtMask = '%lx'\n",
            szError, dwErrors);

        PostWriteToDisplayCtl(lpszOutput, nOutput);
        return TRUE;

    }

    // Should not have gotten here.  Only interested in ERR conditions.

    OutputDebugPrintf("Unexpected comm event %lx",*lpfdwEvtMask);
    return FALSE;
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩黄色影视| 日韩午夜三级在线| 91在线精品一区二区| 色先锋aa成人| 欧美亚洲一区二区三区四区| 91麻豆精品久久久久蜜臀| 久久蜜桃av一区精品变态类天堂 | 毛片一区二区三区| 国产成人在线视频播放| 欧美日韩在线播放一区| 日韩欧美一二三| 国产精品大尺度| 欧美aⅴ一区二区三区视频| 成人在线综合网站| 91视频你懂的| 精品国产区一区| 亚洲一区二区三区视频在线 | 成人激情午夜影院| 91精品国产综合久久香蕉麻豆| 久久久精品国产99久久精品芒果| 亚洲激情第一区| 国产精品18久久久久久久久久久久| 91浏览器在线视频| 久久久综合激的五月天| 天天亚洲美女在线视频| 99久久精品国产观看| 精品剧情v国产在线观看在线| 一区二区视频在线看| 国产成a人亚洲精| 日韩欧美中文一区| 亚洲成人中文在线| 91丝袜美女网| 国产欧美精品一区二区色综合 | 一区二区三区四区高清精品免费观看 | 国产一区不卡在线| 欧美三级乱人伦电影| 国产精品国产三级国产| 亚洲男人的天堂在线观看| 国产精品一区免费视频| 欧美一区二区三区爱爱| 青草av.久久免费一区| www.亚洲色图.com| 国产午夜精品一区二区三区视频 | 在线中文字幕不卡| 国产精品青草综合久久久久99| 狠狠色丁香久久婷婷综| 717成人午夜免费福利电影| 亚洲激情图片小说视频| 色婷婷综合在线| 亚洲综合一区二区三区| 96av麻豆蜜桃一区二区| 久久久久国产成人精品亚洲午夜| 麻豆精品精品国产自在97香蕉 | 91高清在线观看| 国产亚洲精品aa| 国产激情精品久久久第一区二区 | 成人国产免费视频| 国产欧美精品国产国产专区| 蜜臀av性久久久久av蜜臀妖精| 欧美精品在欧美一区二区少妇| 亚洲成人福利片| 欧美一区二区三区在线看| 日本vs亚洲vs韩国一区三区 | 色综合一个色综合亚洲| 中文字幕精品综合| 成人污视频在线观看| 亚洲天堂网中文字| 在线观看欧美日本| 琪琪一区二区三区| 精品国产一区二区三区av性色| 国产米奇在线777精品观看| 久久这里只有精品首页| 成人av网站免费| 亚洲精品乱码久久久久久久久| 欧美亚洲一区二区在线| 久久国产免费看| 国产精品免费网站在线观看| 一本大道久久a久久精二百| 久久精品国产一区二区| 亚洲免费资源在线播放| 精品国产一二三| 欧美在线播放高清精品| 国产精品一区二区久激情瑜伽| 亚洲乱码一区二区三区在线观看| 欧美大片日本大片免费观看| a在线欧美一区| 精品在线一区二区三区| 亚洲国产成人av网| 国产喷白浆一区二区三区| 欧美精品乱码久久久久久| 成人午夜伦理影院| 激情综合网av| 午夜激情久久久| 亚洲人成伊人成综合网小说| 久久久亚洲综合| 日韩欧美在线1卡| 欧美日韩一本到| 色香蕉成人二区免费| 成人国产视频在线观看| 国内精品国产成人国产三级粉色 | 精品制服美女久久| 亚洲成人动漫在线免费观看| 国产精品久久久久久亚洲毛片| 精品国产一二三区| 6080午夜不卡| 欧美日本在线观看| 91久久一区二区| 色综合久久综合网欧美综合网| 国产99久久久国产精品| 寂寞少妇一区二区三区| 蜜桃av一区二区在线观看| 日韩电影在线观看电影| 午夜亚洲福利老司机| 亚洲成av人片一区二区梦乃 | 国产午夜亚洲精品午夜鲁丝片| 日韩一区二区三区四区五区六区| 欧美区一区二区三区| 欧美性猛交xxxxxx富婆| 欧美在线播放高清精品| 欧美特级限制片免费在线观看| 在线亚洲+欧美+日本专区| 在线视频一区二区三区| 欧亚洲嫩模精品一区三区| 色94色欧美sute亚洲13| 在线观看亚洲精品视频| 欧美日韩精品欧美日韩精品| 欧美人xxxx| 欧美成人vr18sexvr| 欧美精品一区男女天堂| 久久久久久久免费视频了| 久久久美女艺术照精彩视频福利播放| 久久亚洲春色中文字幕久久久| 国产色爱av资源综合区| 中文字幕一区二区不卡| 一区二区三区在线免费播放| 亚洲一区精品在线| 亚洲国产综合人成综合网站| 午夜免费久久看| 日本在线不卡一区| 国产河南妇女毛片精品久久久| 国产精品12区| 色婷婷久久综合| 欧美一区二区三区在| 国产人久久人人人人爽| 国产精品视频一二三| 亚洲一区国产视频| 激情成人综合网| 91污片在线观看| 337p亚洲精品色噜噜狠狠| 久久久久成人黄色影片| 亚洲精品国产无天堂网2021| 亚洲综合网站在线观看| 麻豆成人免费电影| 波波电影院一区二区三区| 欧美高清你懂得| 综合欧美一区二区三区| 日本成人在线一区| www.成人网.com| 日韩一区二区中文字幕| 一区免费观看视频| 美女免费视频一区| 91日韩一区二区三区| 久久综合久久综合久久| 亚洲欧美另类综合偷拍| 久久爱www久久做| 欧美影院午夜播放| 欧美激情一区二区三区在线| 亚洲成人综合在线| 粉嫩蜜臀av国产精品网站| 欧美日韩国产影片| 中文字幕日韩一区二区| 捆绑变态av一区二区三区| 欧美伊人久久久久久午夜久久久久| 精品不卡在线视频| 日本中文字幕不卡| 在线精品视频免费播放| 国产精品成人一区二区艾草| 韩国一区二区三区| 欧美伦理影视网| 亚洲精品久久久久久国产精华液| 成人午夜电影网站| 久久综合九色欧美综合狠狠| 日韩国产在线观看一区| 色综合网色综合| 中文字幕免费一区| 国产毛片一区二区| 精品少妇一区二区三区在线视频| 亚洲日本韩国一区| 蜜桃久久精品一区二区| 欧美日韩一区二区三区在线| 综合在线观看色| 成人小视频免费在线观看| 精品国产免费人成在线观看| 日韩不卡一区二区三区| 欧美撒尿777hd撒尿| 一区二区三区在线视频观看 | 欧美亚洲综合久久| 亚洲男人电影天堂| 97久久超碰国产精品电影| 国产精品乱码人人做人人爱|