mfcintrnotification.c

来自「6410BSP3」· C语言 代码 · 共 65 行

C
65
字号
//
// Copyright (c) Samsung Electronics. Co. LTD.  All rights reserved.
//
/*++
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.

*/


#include <windows.h>

#include "MfcIntrNotification.h"


static HANDLE gMfcDoneEvent = NULL;
static unsigned int  gIntrType = 0;

BOOL CreateInterruptNotification(void)
{
    if (gMfcDoneEvent != NULL)
        return TRUE;

    gMfcDoneEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
    if (gMfcDoneEvent == NULL)
        return FALSE;

    return TRUE;
}

void DeleteInterruptNotification(void)
{
    if (gMfcDoneEvent != NULL)
        CloseHandle(gMfcDoneEvent);

    gMfcDoneEvent = NULL;
}

int SendInterruptNotification(int intr_type)
{
    if (gMfcDoneEvent == NULL)
        return -1;

    SetEvent(gMfcDoneEvent);
    gIntrType = intr_type;

    return 0;
}

int WaitInterruptNotification(void)
{
    DWORD ret;

    if (gMfcDoneEvent == NULL)
        return -1;

    ret = WaitForSingleObject(gMfcDoneEvent, MFC_INTR_NOTI_TIMEOUT);
    if (ret == WAIT_TIMEOUT)
        return MFC_INTR_REASON_INTRNOTI_TIMEOUT;

    return gIntrType;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?