How to activate message queue service in WEC2013 running on Apalis T30

Dear toradex Team,

I want to do interprocess communication between a c++ app and a vb.net app on T30. I activated the Option Message Queuing (MSMQ) in Catalog Items View of Image. But running the application it runs to an exeption: “Message Queue service is not available.” in vb.net app. Here are the Code snipets:

c++:

     //Init
     MSGQUEUEOPTIONS opt;
     opt.dwSize = sizeof(MSGQUEUEOPTIONS);
     opt.dwFlags = MSGQUEUE_NOPRECOMMIT;
     opt.dwMaxMessages = 1;
     opt.cbMaxMessage = 100;
     opt.bReadAccess = FALSE;
     HANDLE hwd = CreateMsgQueue(L"DKMSG", &opt);
     DWORD error;
     //Send Message
     WCHAR szTimeMax[10];
     swprintf_s(szTimeMax, L"%d", MaxZykluszeit);
     WCHAR szString[100] = L"Max. Zykluszeit ";
     wcscat(szString, szTimeMax);
     DWORD dwLen = wcslen(szString);
     if (!WriteMsgQueue(hwd, szString, 2 * dwLen, INFINITE, NULL)) {
           error = GetLastError();
      }

I get Error = 233.

in VB:

   'Init
   Dim msg As New System.Messaging.MessageQueue(".\DKMSG", True)

   Try
      'Receive Message.
      Dim myMessage As System.Messaging.Message = msg.Receive()
      Dim sMessage As String = CType(myMessage.Body, String)
  Catch ex As Exeption

  End Try

Are there any Settings in registry needed?

Dear @JanP,

I have tested native code message queue functionality, it is working. Please download the sample code from here : MsgQueueTest and do the test on your side and let us know the feedback.

If it is working then Could you please convert client native code to C# or vb.net.

Please let us know if you have any other questions.

Hello, its me again,

I thrink I found something here (Message Queue Point-to-Point (Windows CE 5.0) | Microsoft Learn).

There is written: “Note Message queuing in the kernel is not related to the Message Queuing (MSMQ) implementation for Windows CE. For information about MSMQ, see Message Queuing.”

My next Question is: How to implement Message Queue Point-to-Point in c# or vb.net?

Dear raja.tx,

I did it allready. The C++ App side worked allready.

Here is the Code for vb.net for the community:

 'Deklaration
 Private Structure MSGQUEUEOPTIONS
    Dim dwSize As Integer
    Dim dwFlags As Integer
    Dim dwMaxMessages As Integer
    Dim cbMaxMessage As Integer
    Dim bReadAccess As Boolean
End Structure

 'Imports
<DllImport("coredll.dll")> Private Shared Function CreateMsgQueue(name As String, ByRef options As MSGQUEUEOPTIONS) As IntPtr
End Function

<DllImport("coredll.dll")> Private Shared Function ReadMsgQueue(hMsgQ As IntPtr, lpBuffer() As Byte, cbBufSize As UInt32, ByRef lpNumRead As UInt32, dwTimeout As Integer, ByRef pdwFlags As UInt32) As Boolean
End Function


    'Coding, do it in a thread.
    Dim opt As New MSGQUEUEOPTIONS
    opt.dwSize = 20 'Size of MSGQUEUEOPTIONS
    opt.dwFlags = 2 '1 = MSGQUEUE_NOPRECOMMIT; 2 = MSGQUEUE_ALLOW_BROKEN
    opt.dwMaxMessages = 1
    opt.cbMaxMessage = 100
    opt.bReadAccess = True
    Dim hwd As IntPtr = CreateMsgQueue("DKMSG", opt)

    While Not locEnd
        Try
            Dim szMsg(99) As Byte
            Dim dwNR As Integer = 0
            Dim dwFlags As Integer = 0
            Dim br As Boolean = ReadMsgQueue(hwd, szMsg, 100, dwNR, 1000, dwFlags)
            If Not br Then
                'Something was wrong or no message arrived in the timeout
                ShowTextFromMsg("Error at Queue!")
            Else
                Dim sMessage As String = System.Text.Encoding.Unicode.GetString(szMsg, 0, dwNR)
                ShowTextFromMsg(locMessage)
            End If
        Catch ex As Exception

        End Try
    End While

It works fine.

Dear @JanP,

Thank you for letting us know that you found the solution.

Best regards and Good Luck!