i've found a method to enumerates the hard disk drives:
***************************************************************
SelectQuery sq = new System.Management.SelectQuery("Win32_DiskDrive");
ManagementObjectSearcher searcher = new
System.Management.ManagementObjectSearcher(sq);
foreach (System.Management.ManagementObject mo in searcher.Get())
{
Log.Fichier.write(mo.GetText(System.Management.TextFormat.Mof), 0);
str = mo.GetPropertyValue("Model").ToString();
Log.Fichier.write(str, 0);
}
***************************************************************
but is there another class to manipulate them ?
thanks
Not sure what you mean with manipulate them, but if your intention is to
read/write devices you have to open the device using Win32's CreateFile just
like you did in C, wrap the handle in a FileStream and do whatever you like
with the device.
Consider following snippet...
// DllImport signature for CreateFile.
[DllImport("kernel32", SetLastError=true)]
static extern IntPtr CreateFile(
string FileName, // file name
int DesiredAccess, // access mode
System.IO.FileShare ShareMode, // share mode
IntPtr SecurityAttributes, // Security Attr
System.IO.FileMode CreationDisposition, // creation mode
int FlagsAndAttributes, // file attributes
IntPtr hTemplate // template file
);
const int FILE_FLAG_NO_BUFFERING = 0x20000000);
// Open the device for reading, disable buffering
IntPtr handle = CreateFile( "\\.\PHYSICALDRIVE0",
FileAccess.Read,
FileShare.None,
IntPtr.Zero,
FileMode.Open,
FILE_FLAG_NO_BUFFERING,
IntPtr.Zero);
// Wrap the handle in a stream
FileStream stream = new FileStream(handle, acc, blockSize, async);
// use the stream to read from the device
...
Willy.