想在windows下实现一个类似Unix,或者vxworks下的消息队列,但是windows没有直接的API可用,不知道应该如何实现?不知道有没有人做过类似的东东,或者例子。

解决方案 »

  1.   

    去看看Windows2000的源代码? 没有下载过,能不能给个具体的?
      

  2.   

    windows的消息队列定义:
    /*
     * Message Queue structure.
     *
     * Note, if you need to add a WORD sized value,
     * do so after xbtnDblClk.
     */
    typedef struct tagQ {
        MLIST       mlInput;            // raw mouse and key message list.    PTHREADINFO ptiSysLock;         // Thread currently allowed to process input
        ULONG_PTR    idSysLock;          // Last message removed
        ULONG_PTR    idSysPeek;          // Last message peeked    PTHREADINFO ptiMouse;           // Last thread to get mouse msg.
        PTHREADINFO ptiKeyboard;    PWND        spwndCapture;
        PWND        spwndFocus;
        PWND        spwndActive;
        PWND        spwndActivePrev;    UINT        codeCapture;
        UINT        msgDblClk;
        WORD        xbtnDblClk;
        DWORD       timeDblClk;
        HWND        hwndDblClk;
        POINT       ptDblClk;    BYTE        afKeyRecentDown[CBKEYSTATERECENTDOWN];
        BYTE        afKeyState[CBKEYSTATE];    CARET       caret;    PCURSOR     spcurCurrent;
        int         iCursorLevel;    DWORD       QF_flags;            // QF_ flags go here    USHORT      cThreads;            // Count of threads using this queue
        USHORT      cLockCount;          // Count of threads that don't want this queue freed    UINT        msgJournal;
        LONG_PTR    ExtraInfo;
    } Q;详细处理过程,在ntos\w32\ntuser\kernel\input.c里头。