これは私がこれまでに持っているものです:
どのボリュームがマウント/マウント解除されているかをユーザーに通知する C# で記述されたカスタム アプリを作成しています。それらがマウントされている場合は、ユーザーにどのドライブに通知する必要があります。ボリュームがマウントされているかどうかを知るために、次のクラスがあります。
このプログラムは、 http://technet.microsoft.com/en-us/sysinternals/bb896655.aspxhandle.exe
またはhttp://download.sysinternals.com/files/Handle.zipからダウンロードできます。
また、管理者としてプログラムを実行している必要があると思います
class TrueCryptHelp
{
// I have that program on the working directory
// it can be downloaded from http://technet.microsoft.com/en-us/sysinternals/bb896655.aspx
const string HandleExeLocation = "handle.exe";
static string systemProcessFiles;
static DateTime dateFilesLockedInfo = new DateTime();
static string SystemProcessFiles
{
get
{
if ((DateTime.Now - dateFilesLockedInfo).TotalSeconds > 2)
{
Process p = new Process();
var psi = new ProcessStartInfo();
psi.RedirectStandardOutput = true;
psi.UseShellExecute = false;
psi.FileName = HandleExeLocation;
p.StartInfo = psi;
p.Start();
var output = p.StandardOutput.ReadToEnd();
systemProcessFiles = string.Empty;
foreach (Match m in Regex.Matches(output ?? "", @"(?sx) -{20} [^-] .+? -{20}"))
{
if (Regex.Match(m.Value ?? "", @"(?xi) -{10} [\s\r\n]+ System \s pid").Success)
{
if (Regex.Match(m.Value ?? "", @"(?xi) \) \s+ \\clfs \s* (\r|\n)").Success)
{
systemProcessFiles = m.Value.ToLower();
break;
}
}
}
}
dateFilesLockedInfo = DateTime.Now;
return systemProcessFiles;
}
}
public static bool IsVolumeMounted(string volumeLocation)
{
//DriveInfo d = new System.IO.DriveInfo(volume.DriveLetter);
//if (d == null)
//return false;
//if (d.DriveType != System.IO.DriveType.Fixed)
//return false;
//if ((d.DriveFormat ?? "").ToLower().Contains("fat") == false)
//return false;
if (SystemProcessFiles.Contains(volumeLocation.ToLower()))
{
return true;
}
else
{
return false;
}
}
}
C:\Users\Tono\Desktop\v1.tc
次に、にあるボリュームがマウントされているかどうかを知りたい場合は、次のようにメソッドを呼び出します。
var isVolMounted = TrueCryptHelp.IsVolumeMounted(@"A:\Users\Tono\Desktop\v1.tc");
今、私は質問に答えることができません!私が投稿したクラスでは、C:\Users\etc... にあるボリュームがどのドライブ文字にマウントされているかを知ることができます!?