易丰科技

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 3249|回复: 0
打印 上一主题 下一主题

代码:查询其他主机的磁碟空间

[复制链接]

111

主题

117

帖子

3588

积分

论坛元老

Rank: 8Rank: 8

积分
3588
跳转到指定楼层
楼主
发表于 2011-10-12 15:44:52 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
  1. ConnectionOptions options = new ConnectionOptions();
  2.             options.Username = UserName;
  3.             options.Password = Password;
  4.             options.Authority = "ntlmdomain:FAREAST";
  5.             ManagementScope scope = new ManagementScope(@"\\" + machinename + @"\root\cimv2", options);
  6.             scope.Connect();
  7.             ObjectQuery query = new ObjectQuery("select * from Win32_LogicalDisk");
  8.             ManagementObjectSearcher searcher =
  9.             new ManagementObjectSearcher(scope, query);

  10.             ManagementObjectCollection queryCollection = searcher.Get();

  11.             foreach (ManagementObject nic in queryCollection)
  12.             {
  13.                 foreach (PropertyData property in nic.Properties)
  14.                     Console.WriteLine(property.Name + "\t\t" + property.Value);
  15.             }
复制代码

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|易丰科技

GMT+8, 2024-10-13 19:23 , Processed in 0.042172 second(s), 20 queries .

Powered by Discuz! X3

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表