Message Queue Implementation RRS feed

  • Question

  • Hi,


    I am using RequestDeviceNotifications() for getting usb attach dettach information. For this i am using

    CreateMsgQueue() with read access and lpszName set to NULL.


    My clarifications:


    1. Who is sending the device add/removal notification to my message Q?


    2. If i used read acess for message queue, is it possible to write message to this message Q?\


    3 How is it possible to get handle to the message Q with out knowing its name? or uniquenes??


    Please guide me.


    Thank you in advance.


    Wince User


    Monday, December 5, 2011 6:06 AM

All replies

  • 1) In Windows Embedded CE 6.0 it's filesys module; before it was the device manager

    2) If you create a read queue (MSGQUEUEOPTIONS::bReadAccess== TRUE) calling CreateMsgQueue you cannot write on it using the same handle you get back from the function. If you created a named queue (which it's not your case) you can call CreateMsgQueue a second time with MSGQUEUEOPTIONS::bReadAccess== FALSE using the same queue name and the function will return a write handle. If the queue has no name you can use OpenMsgQueue passing the read handle you get from the first CreateMsgQueue and MSGQUEUEOPTIONS::bReadAccess== FALSE.

    3) As said before if you know the queue handle and the handle to the source process that owns it you can use OpenMsgQueue to obtain other handles even without knowing the queue name. With the same data you can also use a more 'general' function like DuplicateHandle

    If you installed the shared souce code you can take a look at the msgq implementation in %_WINCEROOT%\PRIVATE\WINCEOS\COREOS\NK\MSGQUEUE\msgqueue.c

    Luca Calligaris lucaDOTcalligarisATeurotechDOTcom Check my blog:
    Monday, December 5, 2011 7:22 AM