GetDriveType.cpp
资源名称:pciexp.zip [点击查看]
上传用户:zhuqijet
上传日期:2007-01-04
资源大小:138k
文件大小:2k
源码类别:
驱动编程
开发平台:
Visual C++
- #include "stdafx.h"
- /****************************************************************************
- * getDriveType
- * Inputs:
- * LPCTSTR fullpath: Full path to some destination
- * Result: UINT
- * DRIVE_ value as returned by GetDriveType
- * Effect:
- * Properly splits up the input string and figures out how to call
- * GetDriveType
- * Notes:
- * Handles the special case of \.name, and a path that includes
- * a file name
- ****************************************************************************/
- UINT getDriveType(LPCTSTR fullpath)
- {
- TCHAR drv[_MAX_PATH];
- TCHAR path[_MAX_PATH];
- TCHAR filename[_MAX_PATH];
- TCHAR ext[_MAX_PATH];
- _splitpath(fullpath, drv, path, filename, ext);
- if(lstrlen(drv) != 0)
- { /* drv */
- return GetDriveType(drv);
- } /* drv */
- else
- { /* what else? */
- // The trick here is that if the path starts with \, we try
- // GetDeviceType. If it returns DRIVE_NO_ROOT_DIR, we call
- // this function recursively
- // If it does not start with \, we return the result directly
- UINT result = GetDriveType(path);
- if(lstrlen(path) > 4 && path[0] == _T('\') && path[1] == _T('\')
- && path[2] == _T('.') && path[3] == _T('\'))
- { /* \. */
- LPTSTR p = &path[4]; // \.c
- // ^
- LPTSTR b = strchr(p, _T('\'));
- if(b != NULL)
- *b = _T(':');
- else
- lstrcat(p, _T(":"));
- return GetDriveType(p);
- } /* \. */
- if(lstrlen(path) < 2 || path[0] != _T('\') || path[1] != _T('\'))
- return result;
- return GetDriveType(path);
- } /* what else? */
- }