Enumerate all outgoing Queues in MSMQ, C#

帅比萌擦擦* 提交于 2019-12-04 02:18:15

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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!