Notices

Water Fountain General Chit/Chat

Reply
 
LinkBack Thread Tools
Old 04-17-04, 10:06 AM   #1 (permalink)
Aximsite Prospect
 
kossu's Avatar
DAP Rookie
 
Join Date: Apr 2004
Posts: 4
Thanked 0 Times in 0 Posts
MSMQ with compact framework

Hi

I have been trying to implement MSMQ on pocket PC 2003 using vb.net. I have been using Platform invoke to call functions msmqrt.dll . I have managed to open and close the queue, but i have not managed to send anything. I am getting MQ_ERROR_ILLEGAL_PROPERTY_VALUE for the PROPID_M_BODY property. Has any one managed to get this thing to work?

i have been following the instruction laid out here:

http://groups.google.com.gr/groups?h...tngxa08&rnum=2

Thanks

Kossu

-----source for the class--------
Code:
Public Class MSMQ

    Public Const MQ_DENY_NONE As Integer = 0
    Public Const MQ_SEND_ACCESS As Integer = 2
    Public Const MQ_NO_TRANSACTION As Integer = 0
    'Message Properties
    Public Const PROPID_M_BODY As Int32 = 9
    Public Const PROPID_M_BODY_SIZE As Int32 = 10
    Public Const PROPID_M_LABEL As Int32 = 11
    Public Const PROPID_M_LABEL_LEN As Int32 = 12
    Public Const PROPID_M_BODY_TYPE As Int32 = 42
    'Queue Properties
    Public Const PROPID_Q_PATHNAME As Int32 = 103


    Public Enum VARENUM

        VT_EMPTY = 0
        VT_NULL = 1
        VT_I2 = 2
        VT_I4 = 3
        VT_R4 = 4
        VT_R8 = 5
        VT_CY = 6
        VT_DATE = 7
        VT_BSTR = 8
        VT_DISPATCH = 9
        VT_ERROR = 10
        VT_BOOL = 11
        VT_VARIANT = 12
        VT_UNKNOWN = 13
        VT_DECIMAL = 14
        VT_I1 = 16
        VT_UI1 = 17
        VT_UI2 = 18
        VT_UI4 = 19
        VT_I8 = 20
        VT_UI8 = 21
        VT_INT = 22
        VT_UINT = 23
        VT_VOID = 24
        VT_HRESULT = 25
        VT_PTR = 26
        VT_SAFEARRAY = 27
        VT_CARRAY = 28
        VT_USERDEFINED = 29
        VT_LPSTR = 30
        VT_LPWSTR = 31
        VT_RECORD = 36
        VT_FILETIME = 64
        VT_BLOB = 65
        VT_STREAM = 66
        VT_STORAGE = 67
        VT_STREAMED_OBJECT = 68
        VT_STORED_OBJECT = 69
        VT_BLOB_OBJECT = 70
        VT_CF = 71
        VT_CLSID = 72
        VT_VERSIONED_STREAM = 73
        VT_BSTR_BLOB = &HFFF&
        VT_VECTOR = &H1000&
        VT_ARRAY = &H2000&
        VT_BYREF = &H4000&
        VT_RESERVED = &H8000&
        VT_ILLEGAL = &HFFFF&
        VT_ILLEGALMASKED = &HFFF&
        VT_TYPEMASK = &HFFF&
    End Enum
    <StructLayout(LayoutKind.Sequential)> Public Structure MQMSGPROPS
        Public cProp As Int32
        Public aPropID As IntPtr
        Public aPropVar As IntPtr
        Public aStatus As IntPtr
    End Structure

    <DllImport("msmqrt.dll")> Public Shared Function MQSendMessage(ByVal Queue As Int32, ByRef pMessageProps As MQMSGPROPS, ByRef Transaction As Int32) As IntPtr

    End Function

    <DllImport("msmqrt.dll")> Public Shared Function MQOpenQueue(ByVal lpwcsFormatName As String, ByVal dwAccess As Int32, ByVal dwShareMode As Int32, ByRef Queue As Int32) As IntPtr

    End Function

    <DllImport("msmqrt.dll")> Public Shared Function MQCloseQueue(ByVal hQueue As Int32) As IntPtr

    End Function
     
   
End Class
--------source for calling the send------------
Code:
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

       Dim Qh As Int32
'open queue
       X.MQOpenQueue("DIRECT=OS:amd2600\private$\test", MSMQ.MQ_SEND_ACCESS, MSMQ.MQ_DENY_NONE, Qh)

        'send 
        Const NUMBEROFPROPERTIES As Int32 = 5
        Dim X As New MSMQ
        Dim R As IntPtr
        Dim addr As Int32
        Dim P As MSMQ.MQMSGPROPS
        Dim aVar(NUMBEROFPROPERTIES * 4) As Int32

        Dim propIDs(NUMBEROFPROPERTIES) As Int32
        Dim aStat(NUMBEROFPROPERTIES) As Int32
        propIDs(0) = X.PROPID_M_BODY 'VT_VECTOR | VT_UI1 
        propIDs(1) = X.PROPID_M_BODY_SIZE 'VT_UI4 (or VT_NULL)  
        propIDs(2) = X.PROPID_M_BODY_TYPE 'VT_UI4 (or VT_NULL) 
        propIDs(3) = X.PROPID_M_LABEL 'VT_LPWSTR 
        propIDs(4) = X.PROPID_M_LABEL_LEN 'VT_UI4 
        'propIDs(5) = X.PROPID_M_LABEL_LEN 'VT_UI4  


        P.cProp = NUMBEROFPROPERTIES
        'properties
        Dim handle As GCHandle = GCHandle.Alloc(propIDs, GCHandleType.Pinned)
        addr = handle.AddrOfPinnedObject.ToInt32() + 4
        P.aPropID = IntPtr.op_Explicit(addr)
        'status
        Dim handle2 As GCHandle = GCHandle.Alloc(aStat, GCHandleType.Pinned)
        addr = handle2.AddrOfPinnedObject.ToInt32() + 4
        P.aStatus = IntPtr.op_Explicit(addr)
        '''1 'X.PROPID_M_BODY 'VT_VECTOR | VT_UI1 
        aVar(0) = MSMQ.VARENUM.VT_VECTOR
        aVar(1) = Nothing
        aVar(2) = 4 'length of the string ?
        aVar(3) = MakeCText("Test")
        ''2 'X.PROPID_M_BODY_SIZE 'VT_UI4 (or VT_NULL) 
        aVar(4) = MSMQ.VARENUM.VT_UI4
        aVar(5) = Nothing
        aVar(6) = 6
        aVar(7) = Nothing

        ''3 'X.PROPID_M_BODY_TYPE 'VT_UI4 (or VT_NULL) 
        aVar(8) = MSMQ.VARENUM.VT_UI4
        aVar(9) = Nothing
        aVar(10) = 0
        aVar(11) = Nothing
        ''4 'X.PROPID_M_LABEL 'VT_LPWSTR 
        aVar(12) = MSMQ.VARENUM.VT_LPWSTR
        aVar(13) = Nothing
        aVar(14) = MakeCText("TEXT1")
        aVar(15) = Nothing
        ''5 'X.PROPID_M_LABEL_LEN 'VT_UI4 
        aVar(16) = MSMQ.VARENUM.VT_UI4
        aVar(17) = Nothing
        aVar(18) = 5
        aVar(19) = Nothing

        ' P.aPropVar 
        Dim handle3 As GCHandle = GCHandle.Alloc(aVar, GCHandleType.Pinned)
        addr = handle3.AddrOfPinnedObject.ToInt32() + 4
        P.aPropVar = IntPtr.op_Explicit(addr)


        R = X.MQSendMessage(Qh, P, X.MQ_NO_TRANSACTION)
        MsgBox("send result:" & R.ToString)
        MsgBox("1:" & aStat(0))
        MsgBox("2:" & aStat(1))
        MsgBox("3:" & aStat(2))
        MsgBox("4:" & aStat(3))
        MsgBox("5:" & aStat(4))
    End Sub
-----------helper function---------
Code:
Private Function MakeCText(ByRef s As String) As Int32
        Dim handle As GCHandle = GCHandle.Alloc(s, GCHandleType.Pinned)
        Dim addr As Int32 = handle.AddrOfPinnedObject.ToInt32() + 4
        Return IntPtr.op_Explicit(addr).ToInt32
    End Function

Last edited by kossu; 04-19-04 at 04:33 PM.
kossu is offline   Reply With Quote
Sponsor Ads
Old 04-17-04, 01:27 PM   #2 (permalink)
dudeman0501
Guest
 
Posts: n/a
From now on, please use the [code] tag when posting code.
  Reply With Quote
Old 04-17-04, 02:13 PM   #3 (permalink)
Aximsite Administrator
 
deftech's Avatar
Addicted Member
 
Join Date: Feb 2003
Location: Arkansas
Posts: 5,635
Thanked 3 Times in 2 Posts

Awards Showcase
Moderator Medal Admin Medal Bronze Poster 
Total Awards: 3

Fixed for him....

Much more readable now. :)
__________________
Jordan M. Wigley
Aximsite.com
Email: jordan AT aximsite.com


.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Come join the friendly community at
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
deftech is offline   Reply With Quote
Reply

Sponsor Ads

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 11:54 PM.
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Copyright © 2003-09 LeckMedia, LLC