GetLogicalDriveStrings()和GetDirveType()
2008-06-28 17:21
453 查看
GetLogicalDriveStrings()
win32 API中获取系统分区信息的函数。。
函数将所有盘符信息以lpBuffer返回,以譬如 "A:\<null>C:\<null>F:\<null><null>"这样的格式。。
当然。我们可以将其分离出来。。大致代码如下:
DWORD len;
char *pBuffer=new char[30];
devl=GetLogicalDriveStrings(100,dev);
string DvName[20];
int n=0;
while(*pBuffer)
{
DvName[n++]=pBuffer;
while(*dev!='\0')dev++;
dev++;
}
GetDirveType()
win32 API中获取分区类型的函数。。
lpRootPathName 包含了根目录路径的字符串指针
返回值
DRIVE_UNKNOWN 未知的磁盘类型
DRIVE_NO_ROOT_DIR 说明lpRootPathName是无效的
DRIVE_REMOVABLE 可移动磁盘
DRIVE_FIXED 固定磁盘
DRIVE_REMOTE 网络磁盘
DRIVE_CDROM 光驱
DRIVE_RAMDISK 为RAM
借助这两个函数。我们便可在程序中。获取系统的分区信息和各分区的类型。。结合一下。也可以用来确定我们要找的分区
win32 API中获取系统分区信息的函数。。
DWORD GetLogicalDriveStrings( DWORD nBufferLength, // size of buffer LPTSTR lpBuffer // drive strings buffer );
nBufferLength [in] Specifies the maximum size, in characters, of the buffer pointed to by lpBuffer. This size does not include the terminating null character. lpBuffer [out] Pointer to a buffer that receives a series of null-terminated strings, one for each valid drive in the system, that end with a second null character. The following example shows the buffer contents with <null> representing the terminating null character.
函数将所有盘符信息以lpBuffer返回,以譬如 "A:\<null>C:\<null>F:\<null><null>"这样的格式。。
当然。我们可以将其分离出来。。大致代码如下:
DWORD len;
char *pBuffer=new char[30];
devl=GetLogicalDriveStrings(100,dev);
string DvName[20];
int n=0;
while(*pBuffer)
{
DvName[n++]=pBuffer;
while(*dev!='\0')dev++;
dev++;
}
GetDirveType()
win32 API中获取分区类型的函数。。
UINT GetDriveType( LPCTSTR lpRootPathName // root directory );
lpRootPathName 包含了根目录路径的字符串指针
返回值
DRIVE_UNKNOWN 未知的磁盘类型
DRIVE_NO_ROOT_DIR 说明lpRootPathName是无效的
DRIVE_REMOVABLE 可移动磁盘
DRIVE_FIXED 固定磁盘
DRIVE_REMOTE 网络磁盘
DRIVE_CDROM 光驱
DRIVE_RAMDISK 为RAM
借助这两个函数。我们便可在程序中。获取系统的分区信息和各分区的类型。。结合一下。也可以用来确定我们要找的分区
相关文章推荐
- GetLogicalDrives,GetLogicalDriveStrings,GetDriveType
- GetLogicalDriveStrings和GetDriveType
- Windows API 逐个逐个学MessageBox(5) 遍历驱动器并获取驱动器属性 GetLogicalDriveStrings、GetDriveTypeA
- GetLogicalDrives|GetLogicalDriveStrings|GetDriveType-穷举系统所有驱动器
- 用GetLogicalDriveStrings或FindFirstVoum两种方法获取主机驱动器列表
- 使用GetLogicalDriveStrings获取驱动器根路径
- WinAPI: GetLogicalDriveStrings - 获取系统中存在的逻辑驱动器字符串
- WindowsAPI详解——GetLogicalDriveStrings 枚举系统逻辑磁盘
- 使用GetLogicalDriveStrings
- error C2664: “DWORD GetLogicalDriveStringsA(DWORD,LPSTR)”: 无法将参数 2 从“wchar_t *”转换为“LPSTR”
- GetLogicalDriveStrings
- 获得磁盘驱动器号GetLogicalDriveStrings,HeapAlloc
- Windows API ——GetLogicalDriveStrings——获取逻辑驱动器
- Windows API ——GetLogicalDriveStrings——获取逻辑驱动器
- GetLogicalDriveStrings的体验
- 获得磁盘驱动器号GetLogicalDriveStrings,HeapAlloc
- 利用GetLogicalDrives和GetDriveType获取驱动器盘符及类型
- Windows API ——GetLogicalDriveStrings——获取逻辑驱动器
- GetLogicalDriveStrings函数
- GetLogicalDriveStrings函数