wchar:wchar是可以保存utf-8字符的字符串
头文件:wchar.h
初始化:WCHAR Driver_Path[4]=TEXT("C:\");
GetLogicalDrives:这个是看计算机中有哪些磁盘
返回值:32位整数 DWORD
如何看:将返回值变成2进制,比如返回值是0011那么就表示电脑中有A盘和B盘
例子:
DWORD allDisk = GetLogicalDrives(); //返回一个32位整数,将他转换成二进制后,表示磁盘,最低位为A盘 比如返回00011就表示有a盘和b盘 WCHAR Driver_Path[4]=TEXT("C:\");
if (allDisk != 0)
{
for (int i = 1;i<11;i++) //假定最多有10个磁盘
{
if ((allDisk & 1) == 1) //如果有磁盘i
{
Driver_Path[0] = 'C' + i - 3;
}
allDisk = allDisk >> 1;
}
}
每一个的Driver_Path就保存了这个磁盘的路径
GetDriveType:求磁盘类型
参数:LPCWSTR,其实这个就是指向WCHAR字符串的指针
返回值:
Return code/value | Description |
---|---|
|
The drive type cannot be determined. |
|
The root path is invalid; for example, there is no volume mounted at the specified path. |
|
The drive has removable media; for example, a floppy drive, thumb drive, or flash card reader. |
|
The drive has fixed media; for example, a hard disk drive or flash drive. |
|
The drive is a remote (network) drive. |
|
The drive is a CD-ROM drive. |
|
The drive is a RAM disk. |
例子:
WCHAR Driver_Path[4]=TEXT("C:\"); GetDriveType(Driver_Path);