VS 2005 c#中 怎样获得系统盘的盘符?(c:\或者d:\)
Directory.GetCurrentDirectory()是用来获取当前程序目录的那如果我想获得系统盘的目录呢?比如c:\有些人是d:\该怎么做?还有我想让一个FOR...
Directory.GetCurrentDirectory()是用来获取当前程序目录的
那如果我想获得系统盘的目录呢?
比如c:\有些人是d:\ 该怎么做?
还有
我想让一个FORM右上角只有"打叉"的图标,而没有"最小化"和"最大化"的图标,应该怎么做? 展开
那如果我想获得系统盘的目录呢?
比如c:\有些人是d:\ 该怎么做?
还有
我想让一个FORM右上角只有"打叉"的图标,而没有"最小化"和"最大化"的图标,应该怎么做? 展开
展开全部
问题1:
wmi
ManagementObjectSearcher query = new ManagementObjectSearcher("SELECT * From Win32_LogicalDisk ");
ManagementObjectCollection queryCollection = query.Get();
//loop throught each object to get drive information
foreach ( ManagementObject mo in queryCollection)
{
switch (int.Parse( mo["DriveType"].ToString()))
{
case Removable: //removable drives
imageIndex = 5;
selectIndex = 5;
break;
case LocalDisk: //Local drives
imageIndex = 6;
selectIndex = 6;
break;
case CD: //CD rom drives
imageIndex = 7;
selectIndex = 7;
break;
case Network: //Network drives
imageIndex = 8;
selectIndex = 8;
break;
default: //defalut to folder
imageIndex = 2;
selectIndex = 3;
break;
}
//get drive name
Console.WriteLine("Drive: " + mo["Name"].ToString());
}
问题2:
设置FORM的MaximizeBox 为false 就可以
wmi
ManagementObjectSearcher query = new ManagementObjectSearcher("SELECT * From Win32_LogicalDisk ");
ManagementObjectCollection queryCollection = query.Get();
//loop throught each object to get drive information
foreach ( ManagementObject mo in queryCollection)
{
switch (int.Parse( mo["DriveType"].ToString()))
{
case Removable: //removable drives
imageIndex = 5;
selectIndex = 5;
break;
case LocalDisk: //Local drives
imageIndex = 6;
selectIndex = 6;
break;
case CD: //CD rom drives
imageIndex = 7;
selectIndex = 7;
break;
case Network: //Network drives
imageIndex = 8;
selectIndex = 8;
break;
default: //defalut to folder
imageIndex = 2;
selectIndex = 3;
break;
}
//get drive name
Console.WriteLine("Drive: " + mo["Name"].ToString());
}
问题2:
设置FORM的MaximizeBox 为false 就可以
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询