コード例 #1
0
    private static unsafe uint getCount(string path)
    {
        MQMGMTPROPS props = new MQMGMTPROPS();
        props.cProp = 1;

        int aPropId = PROPID_MGMT_QUEUE_MESSAGE_COUNT;
        props.aPropID = &aPropId;

        MQPROPVariant aPropVar = new MQPROPVariant();
        aPropVar.vt = VT_NULL;
        props.aPropVar = &aPropVar;

        int status = 0;
        props.status = &status;

        IntPtr objectName = Marshal.StringToBSTR("queue=Direct=OS:" + path);
        try
        {
            int result = MQMgmtGetInfo(null, (char*)objectName, &props);
            if (result != 0 || *props.status != 0 || props.aPropVar->vt != VT_UI4)
            {
                return 0;
            }
            else
            {
                return props.aPropVar->ulVal;
            }
        }
        finally
        {
            Marshal.FreeBSTR(objectName);
        }
    }
コード例 #2
0
        /// <summary>
        /// The get count.
        /// </summary>
        /// <param name="path">
        /// The path.
        /// </param>
        /// <returns>
        /// The <see cref="uint"/>.
        /// </returns>
        private static unsafe uint GetCount(string path)
        {
            if (!MessageQueue.Exists(path))
            {
                return(0);
            }

            var props = new MQMGMTPROPS();

            props.cProp = 1;

            var aPropId = PROPID_MGMT_QUEUE_MESSAGE_COUNT;

            props.aPropID = &aPropId;

            var aPropVar = new MQPROPVariant();

            aPropVar.vt    = VT_NULL;
            props.aPropVar = &aPropVar;

            var status = 0;

            props.status = &status;

            var objectName = Marshal.StringToBSTR("queue=Direct=OS:" + path);

            try
            {
                uint rtn;

                lock (LockObject)
                {
                    var result = MQMgmtGetInfo(null, (char *)objectName, &props);
                    if (result != 0 || *props.status != 0 || props.aPropVar->vt != VT_UI4)
                    {
                        rtn = 0;
                    }
                    else
                    {
                        rtn = props.aPropVar->ulVal;
                    }
                }

                return(rtn);
            }
            finally
            {
                Marshal.FreeBSTR(objectName);
            }
        }
コード例 #3
0
        public static unsafe uint GetCount(string path)
        {
            if (!MessageQueue.Exists(path))
            {
                return(0);
            }

            MQMGMTPROPS props = new MQMGMTPROPS();

            props.cProp = 1;

            int aPropId = PROPID_MGMT_QUEUE_MESSAGE_COUNT;

            props.aPropID = &aPropId;

            MQPROPVariant aPropVar = new MQPROPVariant();

            aPropVar.vt    = VT_NULL;
            props.aPropVar = &aPropVar;

            int status = 0;

            props.status = &status;

            IntPtr objectName = Marshal.StringToBSTR("queue=Direct=OS:" + path);

            try
            {
                int result = MQMgmtGetInfo(null, (char *)objectName, &props);
                if (result != 0 || *props.status != 0 || props.aPropVar->vt != VT_UI4)
                {
                    return(0);
                }
                else
                {
                    return(props.aPropVar->ulVal);
                }
            }
            finally
            {
                Marshal.FreeBSTR(objectName);
            }
        }
コード例 #4
0
        private static unsafe uint GetCount(string path)
        {
            var props = new MQMGMTPROPS {
                cProp = 1
            };
            var aPropId = PROPID_MGMT_QUEUE_MESSAGE_COUNT;

            props.aPropID = &aPropId;

            var aPropVar = new MQPROPVariant {
                vt = VT_NULL
            };

            props.aPropVar = &aPropVar;

            var status = 0;

            props.status = &status;

            var objectName = Marshal.StringToBSTR("queue=Direct=OS:" + path);

            try
            {
                var result = MQMgmtGetInfo(null, (char *)objectName, &props);
                if (result != 0 || *props.status != 0 || props.aPropVar->vt != VT_UI4)
                {
                    return(0);
                }
                else
                {
                    return(props.aPropVar->ulVal);
                }
            }
            finally
            {
                Marshal.FreeBSTR(objectName);
            }
        }
コード例 #5
0
        /// <summary>
        /// The get count.
        /// </summary>
        /// <param name="path">
        /// The path.
        /// </param>
        /// <returns>
        /// The <see cref="uint"/>.
        /// </returns>
        private static unsafe uint GetCount(string path)
        {
            if (!MessageQueue.Exists(path))
            {
                return 0;
            }

            var props = new MQMGMTPROPS();
            props.cProp = 1;

            var aPropId = PROPID_MGMT_QUEUE_MESSAGE_COUNT;
            props.aPropID = &aPropId;

            var aPropVar = new MQPROPVariant();
            aPropVar.vt = VT_NULL;
            props.aPropVar = &aPropVar;

            var status = 0;
            props.status = &status;

            var objectName = Marshal.StringToBSTR("queue=Direct=OS:" + path);
            try
            {
                uint rtn;

                lock (LockObject)
                {
                    var result = MQMgmtGetInfo(null, (char*) objectName, &props);
                    if (result != 0 || *props.status != 0 || props.aPropVar->vt != VT_UI4)
                    {
                        rtn = 0;
                    }
                    else
                    {
                        rtn = props.aPropVar->ulVal;
                    }
                }

                return rtn;
            }
            finally
            {
                Marshal.FreeBSTR(objectName);
            }
        }