枚举所有MSMQ传出队列,C# [英] Enumerate all outgoing Queues in MSMQ, C#

查看:484
本文介绍了枚举所有MSMQ传出队列,C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用C#和.NET 3.5,我怎么能得到所有MSMQ传出队列的列表?我发现这篇文章吧但正如你可以看到下面我没有为<$的COM入口C $ C> Microsoft消息队列3.0对象库 ...

Using C# and .NET 3.5, how can I get a listing of all outgoing queues in MSMQ? I found this article about it but as you can see below I do not have the COM entry for Microsoft Message Queue 3.0 Object Library...

那么,如何可以获取当前传出队列上市?我想一定有办法,因为我可以看到他们在计算机管理 ...

So how can I get the current outgoing queue listing? I figured there must be a way since I can see them in Computer Management...

我该怎么办?

推荐答案

两个很好的地方开始,我认为会是这些:

Two good places to start I think would be these:

http://msdn.microsoft.com/en-us/库/ ms703173%28V = vs.85%29.aspx

http://msdn.microsoft.com/en-us/library/ms711378%28v=vs.85%29.aspx

我要看看我是否可以工作了一些代码。

I'll see if I can work up some code.

也许没有,那些看起来老了,还在找。

Perhaps not, those look old, still looking.

下面有一些WScript的,将他们展示给你,还在寻找的.Net代码:

Heres some WScript that will show them to you, still looking for .Net code:

Dim Locator
Set Locator = CreateObject("WbemScripting.SWbemLocator")
Dim objs
Set Service = Locator.ConnectServer(".", "root\cimv2")
Set objs = Service.ExecQuery("Select * From Win32_PerfRawData_MSMQ_MSMQQueue")
For Each object In objs
    WScript.Echo "Name: " & object.Name
Next 







using System.Management;
namespace TestMSMQStuff
{
    class Program
    {

        static void Main(string[] args)
        {

            System.Management.SelectQuery q = new SelectQuery("Select * From Win32_PerfRawData_MSMQ_MSMQQueue");
            ManagementObjectSearcher s = new ManagementObjectSearcher(q);
            foreach (var r in s.Get())
            {
                Console.WriteLine(r.Properties["Name"].Value);
            }
        }
    }
}



相貌像所有传出队列开始OS:

Looks like all the outgoing queues start with "os:"

需要将引用System.Management和System.Management.Instrumentation

Need to references System.Management and System.Management.Instrumentation

这篇关于枚举所有MSMQ传出队列,C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆