示例#1
0
        /// <summary>
        /// Create a new point-to-point message queue object.
        /// </summary>
        /// <param name="name">
        /// Indicates the name of a named queue.  Set to null to create
        /// an unnamed queue.
        /// </param>
        /// <param name="maxMessages">
        /// Indicates the length of the queue in messages.
        /// </param>
        /// <param name="maxMessageSize">
        /// Indicates the maximum size of each message in the queue.
        /// </param>
        /// <param name="readAccess">
        /// Set to true if messages will be read from the queue, false
        /// if messages will be written to the queue.  A read/write
        /// queue cannot be created.
        /// </param>
        /// <param name="flags">
        /// Flags indicating how the queue will operate.
        /// </param>
        public PointToPointMsgQueue(string name,
                                    int maxMessages, int maxMessageSize,
                                    bool readAccess, PointToPointMsgQueueFlags flags)
        {
            hMsgQueue = IntPtr.Zero;
            created   = false;

            // Set up the descriptor for the queue, based on the
            // parameters.
            MSGQUEUEOPTIONS opt = new MSGQUEUEOPTIONS();

            opt.dwFlags       = (int)flags;
            opt.dwMaxMessages = maxMessages;
            opt.cbMaxMessage  = maxMessageSize;
            opt.bReadAccess   = (readAccess ? 1 : 0);

            // Actually create the queue.
            hMsgQueue = PointToPointMsgQueuePInvokes.CreateMsgQueue(name, opt);
            if (hMsgQueue != IntPtr.Zero)
            {
                // Get indication of whether we created the queue or
                // if we just attached to an existing queue.
                uint err = PointToPointMsgQueuePInvokes.GetLastError();
                if (err == 0)
                {
                    created = true;
                }
                else
                {
                    created = false;
                }
            }
        }
		/// <summary>
		/// Create a new point-to-point message queue object.
		/// </summary>
		/// <param name="name">
		/// Indicates the name of a named queue.  Set to null to create
		/// an unnamed queue.
		/// </param>
		/// <param name="maxMessages">
		/// Indicates the length of the queue in messages.
		/// </param>
		/// <param name="maxMessageSize">
		/// Indicates the maximum size of each message in the queue.
		/// </param>
		/// <param name="readAccess">
		/// Set to true if messages will be read from the queue, false
		/// if messages will be written to the queue.  A read/write
		/// queue cannot be created.
		/// </param>
		/// <param name="flags">
		/// Flags indicating how the queue will operate.
		/// </param>
		public PointToPointMsgQueue( string name, 
			int maxMessages, int maxMessageSize, 
			bool readAccess, PointToPointMsgQueueFlags flags )
		{
			hMsgQueue = IntPtr.Zero;
			created = false;

			// Set up the descriptor for the queue, based on the
			// parameters.
			MSGQUEUEOPTIONS	opt = new MSGQUEUEOPTIONS();
			opt.dwFlags = (int)flags;
			opt.dwMaxMessages = maxMessages;
			opt.cbMaxMessage = maxMessageSize;
			opt.bReadAccess = ( readAccess ? 1 : 0 );

			// Actually create the queue.
			hMsgQueue = PointToPointMsgQueuePInvokes.CreateMsgQueue( name, opt );
			if ( hMsgQueue != IntPtr.Zero )
			{
				// Get indication of whether we created the queue or
				// if we just attached to an existing queue.
				uint	err = PointToPointMsgQueuePInvokes.GetLastError();
				if ( err == 0 )
				{
					created = true;
				}
				else
				{
					created = false;
				}
			}
		}
示例#3
0
 public static extern IntPtr CreateMsgQueue(string name,
                                            MSGQUEUEOPTIONS opt);
		public static extern IntPtr CreateMsgQueue( string name, 
			MSGQUEUEOPTIONS opt );