100分!熟悉WMI的朋友请看!思归大侠请进

msm 2003-10-15 04:24:45
1、利用WMI启动一个进程后如何订阅有关于这个进程的消息,比如我想知道他执行的情况:成功与否?是否暂停?失败原因等有关情况
2、远程启动一个进程后,没有程序的界面,这个问题怎么解决?

...全文
62 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
turnmissile 2004-03-16
  • 打赏
  • 举报
回复
关于进程间的通讯可以使用MessageQueue。

// This class represents an object the following example
// sends to a queue and receives from a queue.
public class Order
{
public int orderId;
public DateTime orderTime;
};

/// <summary>
/// Provides a container class for the example.
/// </summary>
public class MyNewQueue
{

//**************************************************
// Provides an entry point into the application.
//
// This example sends and receives a message from
// a queue.
//**************************************************

public static void Main()
{
// Create a new instance of the class.
MyNewQueue myNewQueue = new MyNewQueue();

// Send a message to a queue.
myNewQueue.SendMessage();

// Receive a message from a queue.
myNewQueue.ReceiveMessage();

return;
}


//**************************************************
// Sends an Order to a queue.
//**************************************************

public void SendMessage()
{

// Create a new order and set values.
Order sentOrder = new Order();
sentOrder.orderId = 3;
sentOrder.orderTime = DateTime.Now;

// Connect to a queue on the local computer.
MessageQueue myQueue = new MessageQueue(".\\myQueue");

// Send the Order to the queue.
myQueue.Send(sentOrder);

return;
}


//**************************************************
// Receives a message containing an Order.
//**************************************************

public void ReceiveMessage()
{
// Connect to the a queue on the local computer.
MessageQueue myQueue = new MessageQueue(".\\myQueue");

// Set the formatter to indicate body contains an Order.
myQueue.Formatter = new XmlMessageFormatter(new Type[]
{typeof(MyProject.Order)});

try
{
// Receive and format the message.
Message myMessage = myQueue.Receive();
Order myOrder = (Order)myMessage.Body;

// Display message information.
Console.WriteLine("Order ID: " +
myOrder.orderId.ToString());
Console.WriteLine("Sent: " +
myOrder.orderTime.ToString());
}

catch (MessageQueueException)
{
// Handle Message Queuing exceptions.
}

// Handle invalid serialization format.
catch (InvalidOperationException e)
{
Console.WriteLine(e.Message);
}

// Catch other exceptions as necessary.

return;
}
Bob 2004-03-16
  • 打赏
  • 举报
回复
楼主,我介绍你一个好东西吧:
Management (WMI) Extensions for Visual Studio .NET 2003 Server Explorer
http://www.microsoft.com/downloads/details.aspx?displaylang=zh-cn&FamilyID=62d91a63-1253-4ea6-8599-68fb3ef77de1

安装后在VS.NET的“服务器资源管理器”里面多了两个东西,“管理类”和“管理事件”,通过它你可以很快的生成你要的WMI功能,比如关机功能。

步骤如下:
1,展开“管理类”,右击“操作系统”,然后选择“生成管理的类”,就可以得到所有有关操作系统的WMI功能了。你要的关机功能在:OperatingSystem.Win32Shutdown
duibudui 2003-10-17
  • 打赏
  • 举报
回复
借问一下:

wmi怎么用?
Dim p As New ManagementPath("\\.\root\cimv2:Win32_LogicalDisk.Name=""C:""")
有什么错?

TomMax(笑望人生): ms的组件装了,给个例子怎么用吧,怎么读processor信息?
hjwzr 2003-10-17
  • 打赏
  • 举报
回复
谢谢!
维她奶 2003-10-16
  • 打赏
  • 举报
回复
up
msm 2003-10-16
  • 打赏
  • 举报
回复
2003是几张盘的阿?
msm 2003-10-16
  • 打赏
  • 举报
回复
可我机子上装的是vs.net阿,暂时找不到vs.net2003,不让我安装这个组件
  • 打赏
  • 举报
回复
简单,微软已经出了一个vs.net2003的组件,他可以自动生成代码检测系统进程的信息。
看这个帖子:
http://expert.csdn.net/Expert/topic/2354/2354950.xml?temp=.7998163
msm 2003-10-16
  • 打赏
  • 举报
回复
up
无名2018 2003-10-16
  • 打赏
  • 举报
回复
都是些什么东西啊?
请教:)

110,533

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧