IDiskQuotaControl

  • Thread starter Thread starter Toby Mathews
  • Start date Start date
T

Toby Mathews

Hi there,

Can anyone help me get started (preferably in C#) using IDiskQuotaControl
to set disk quotas for users? I am baffled and can only find C++ examples.

Thanks in advance,

Toby Mathews
 
Toby,

You will have to define the IDiskQuotaControl interface in your code,
using the attributes from the System.Runtime.InteropServices namespace.
Once you have this, you can get the type of the COM component from a call to
the static GetTypeFromCLSID method on the Type class. With that, you can
pass the type to the static CreateInstance method on the Activator class,
and cast the return type to the IDiskQuotaControl interface you declared in
code.

Hope this helps.
 
Toby,

This is totally untested and I have no idea if you could use this. But
you
might want to look into the WMI classes in the .NET framework. Here is
some (untested) code to get you started. Perhaps someone can fill in the
blanks.

ManagementObjectSearcher query =
new ManagementObjectSearcher("SELECT * From Win32_DiskQuota");
ManagementObjectCollection queryCollection = query.Get();

foreach ( ManagementObject mo in queryCollection)
Console.WriteLine(mo.ToString());
Console.ReadLine();

Other than this you could use the IDiskQuotaControl interface and any
Disk Quota API:s available in Win32 using p/Invoke.

HTH,

//Andreas

Nicholas Paldino said:
Toby,

You will have to define the IDiskQuotaControl interface in your code,
using the attributes from the System.Runtime.InteropServices namespace.
Once you have this, you can get the type of the COM component from a call to
the static GetTypeFromCLSID method on the Type class. With that, you can
pass the type to the static CreateInstance method on the Activator class,
and cast the return type to the IDiskQuotaControl interface you declared in
code.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)


Toby Mathews said:
Hi there,

Can anyone help me get started (preferably in C#) using IDiskQuotaControl
to set disk quotas for users? I am baffled and can only find C++ examples.

Thanks in advance,

Toby Mathews
 
Andreas,

You can not use the IDiskQuotaControl interface through the P/Invoke
layer, as it is a COM interface. Also if you want to perform operations on
the disk quota instead of just reading it from memory, then you will have to
use the interface, and not WMI.

However, if the OP only wants to get information about the disk quota,
then WMI is definitely an easier way to go.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Andreas Håkansson said:
Toby,

This is totally untested and I have no idea if you could use this. But
you
might want to look into the WMI classes in the .NET framework. Here is
some (untested) code to get you started. Perhaps someone can fill in the
blanks.

ManagementObjectSearcher query =
new ManagementObjectSearcher("SELECT * From Win32_DiskQuota");
ManagementObjectCollection queryCollection = query.Get();

foreach ( ManagementObject mo in queryCollection)
Console.WriteLine(mo.ToString());
Console.ReadLine();

Other than this you could use the IDiskQuotaControl interface and any
Disk Quota API:s available in Win32 using p/Invoke.

HTH,

//Andreas

Nicholas Paldino said:
Toby,

You will have to define the IDiskQuotaControl interface in your code,
using the attributes from the System.Runtime.InteropServices namespace.
Once you have this, you can get the type of the COM component from a
call
to
the static GetTypeFromCLSID method on the Type class. With that, you can
pass the type to the static CreateInstance method on the Activator class,
and cast the return type to the IDiskQuotaControl interface you declared in
code.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)


Toby Mathews said:
Hi there,

Can anyone help me get started (preferably in C#) using IDiskQuotaControl
to set disk quotas for users? I am baffled and can only find C++ examples.

Thanks in advance,

Toby Mathews
 
Or simply use the command line tool fsutil.

Willy.


Andreas Håkansson said:
Toby,

This is totally untested and I have no idea if you could use this. But
you
might want to look into the WMI classes in the .NET framework. Here is
some (untested) code to get you started. Perhaps someone can fill in the
blanks.

ManagementObjectSearcher query =
new ManagementObjectSearcher("SELECT * From Win32_DiskQuota");
ManagementObjectCollection queryCollection = query.Get();

foreach ( ManagementObject mo in queryCollection)
Console.WriteLine(mo.ToString());
Console.ReadLine();

Other than this you could use the IDiskQuotaControl interface and any
Disk Quota API:s available in Win32 using p/Invoke.

HTH,

//Andreas

Nicholas Paldino said:
Toby,

You will have to define the IDiskQuotaControl interface in your code,
using the attributes from the System.Runtime.InteropServices namespace.
Once you have this, you can get the type of the COM component from a call to
the static GetTypeFromCLSID method on the Type class. With that, you can
pass the type to the static CreateInstance method on the Activator class,
and cast the return type to the IDiskQuotaControl interface you declared in
code.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)


Toby Mathews said:
Hi there,

Can anyone help me get started (preferably in C#) using IDiskQuotaControl
to set disk quotas for users? I am baffled and can only find C++ examples.

Thanks in advance,

Toby Mathews
 
Back
Top