CSDN博客

img yangrongcan

利用WMI进行磁盘配额

发表于2004/10/19 10:59:00  815人阅读

You just need to create a new instance of a win32_quotadisk class.  
  
Something like this should do... (error checking omitted!)  
  
.....  
  
ManagementClass c = new ManagementClass("Win32_DiskQuota");  
  
ManagementObject quota = c.CreateInstance();  
  
quota["Limit"] = 400000000;  
  
quota["WarningLimit"] = 200000000;  
  
// Get user account object  
  
ManagementObject account = new  
  
ManagementObject("Win32_Account.Domain=domainName,Name=someUsername");  
  
account.Get();  
  
// get disk object  
  
ManagementObject disk = new  
  
ManagementObject("Win32_LogicalDisk.DeviceId='d:'");  
  
disk.Get();  
  
quota["QuotaVolume"] = disk;  
  
quota["User"] = account;  
  
quota.Put(); // commit  
  
Willy.  
  
"Nikolaj Pedersen via .NET 247" <anonymous@dotnet247.com> wrote in message  
  
news:eKYSgqCLEHA.2388@TK2MSFTNGP09.phx.gbl...
阅读全文
0 0

相关文章推荐

img
取 消
img