Read this document carefully
http://msdn.microsoft.com/en-us/library/ms711398(VS.85).aspx
Be careful that,
- Declare the MSMQEvent object and the MSMQQueue object globally
- If
Opening the watching queue for send access, then don't use new keyword
in MSMQEvent object but if Opening the watching queue for receive
access then must use the new keyword
- Be careful that if you are Opening the watching queue for send accessand using the new keyword then the Error "Access is denied" comes.
The sample exampe is
Private WithEvents oEvent As MSMQ.MSMQEvent
Private myQWatch As MSMQ.MSMQQueue
Public Sub.............
Dim myQWatchInfo As New MSMQ.MSMQQueueInfo
myQWatchInfo.PathName = ".\Private$\WatchQueue"
myQWatch = myQWatchInfo.Open(MSMQ.MQACCESS.MQ_RECEIVE_ACCESS,_ MSMQ.MQSHARE.MQ_DENY_NONE)
oEvent = New MSMQ.MSMQEvent
myQWatch.EnableNotification(oEvent)
MsgBox("EnableNotification is now Running")
End Sub
Shahid Noor
Enter your message below
Sign in or Join us (it's free).