枚举MSMQ中的所有传出队列,C#

发布于 2024-11-13 04:01:26 字数 463 浏览 3 评论 0原文

使用 C# 和 .NET 3.5,如何获取 MSMQ 中所有传出队列的列表?我找到了这篇关于它的文章,但正如你在下面看到的,我没有Microsoft Message Queue 3.0 对象库的 COM 条目...

我不小心使用了 Microsoft Message Queue 3.0 对象图书馆

所以如何获取当前的传出队列列表?我想一定有办法,因为我可以在计算机管理中看到它们...

计算机管理 + MSMQ

我能做什么?

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...

I accidentally the 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...

Computer Management + MSMQ

What can I do?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

谈情不如逗狗 2024-11-20 04:01:26

我认为两个好的起点是:

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

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

我会看看是否可以编写一些代码。


也许不是,那些看起来很旧,但看起来仍然如此。


下面是一些 WScript,将向您展示它们,仍在寻找 .Net 代码:

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:”开头

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

Two good places to start I think would be these:

http://msdn.microsoft.com/en-us/library/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.


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);
            }
        }
    }
}

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文