Skip to main content

Past Blast

Featured Products

Stay in touch using the DEVBUSS RSS feeds.


Programming MSMQ on the PocketPC using eVB

Written by Ken Rabold  [author's bio]  [read 44156 times]
Edited by Derek

Download the code

Page 1  Page 2  Page 3 

To send a message you'll need to create two objects. The first object is the MSMQQueueInfo object. This object is used as a reference object to any queue - local or remote - with which the application wishes to interact. The MSMQQueueInfo object can create new queues, delete queues, set or get the properties of a queue, and open queue instances. This code creates a local private queue named "HelloWorld":

' Create and open local queue for sending
qinfo.PathName = ".\private$\HelloWorld"

The next line of code opens the queue:

Set q = qinfo.Open(MQ_SEND_ACCESS, MQ_DENY_NONE)

The Open method of the MSMQQueueInfo object opens the queue identified by the PathName property and returns a MSMQQueue object. The MSMQQueue object is an open instance of the queue, whereas the MSMQQueueInfo object just represents the queue. There can be multiple MSMQQueue objects opened from a single MSMQQueueInfo object.

The other object used for sending a message is MSMQMessage. The MSMQMessage object has many parameters that can be set that affect the contents and handling of the message. The contents of the message are sent in the Body property. This property is a variant data type and can accept any supported Visual Basic type (String, Integer, Date, Decimal, etc.) The contents of the body and the type information are sent in the MSMQ message. The label and body of the message are set to the text that was entered into the Text1 box. The message is sent by calling the Send method of the MSMQMessage object.

' Send message
m.Label = Text1.Text
m.Body = Text1.Text
m.Send q

Add the msmqInc.bas module to the project. This contains all the constant declarations needed to run this project. The msmqInc.bas file can be found in the Typelib subdirectory of the downloaded source code.

Run the program and press the Send button...and you'll see nothing happen! Actually, a single message will be deposited into the local queue "HelloWorld.". To see the message, use the VISADM.EXE and type "enum queues" in the text box and press the Run button. A list of all the queues on the device will be displayed. Look for the "HelloWorld" queue and find its index number. Use that index number to run the "enum messages <n>" (where <n> is the index of the queue). You should see a list of messages in the queue, one for every Send button press.

To find VISADM.EXE go to your file explorer on your pocket pc (under Programs), and search under My Device-->Program files-->Programming MSMQ.

The HelloWorld sample application contains many more examples of Sending messages and XML to other computers, receiving MSMQ messages synchronously and asynchronously, using send options such as time to live and journaling, and queue management. The electronic book describes in detail the differences between MSMQ on a PocketPC and on the desktop, installation and configuration steps, troubleshooting hints, and it provides a complete reference for the PocketPC MSMQ component.

The final result of the "Hello World" program for MSMQ should provide you with a test-bed to try various aspects of MSMQ on a PocketPC. It can also be the starting point for your own MSMQ PocketPC application. Since the COM API for MSMQ on the PocketPC mimics the desktop version, many of the sample applications that run on the desktop can also be ported to a PocketPC with minimal modification.


Ken Rabold is a Software Architect in the Platform Systems group at BSQUARE Corporation in Bellevue, Washington. A graduate of Seattle University (BSEE) and the University of Washington (MSEE), Ken has worked on distributed systems since 1993. At BSQUARE, Ken is working on enabling XML technology, such as BizTalk and SOAP, for Windows CE devices. Ken was the lead developer on BSQUARE's Remote Device Updater, XML Developer's Kit and CE Transaction Builder for BizTalk. Ken's interest in MSMQ was a result of working on implementing BizTalk technology for Windows CE.

Previous Page