This
subroutine handles
GetDeviceType when you
have an arbitrary path. There are
three problems with the
GetDeviceType API: (1) if
you have a path which contains a
file name, it returns the error code
DRIVE_NO_ROOT_DIR; (2) it works
differently on Windows NT and
Windows 95; (3) if you pass it a
string that contains a name like
"\\.\d\" it does not recognize the
local drive. This code fixes these
problems. It strips back the name
until it has either a drive letter
(C:, for example), or a network path
name (\\ prefix). It discards any
file name portion. It also handles
paths that do not contain a drive or
UNC name. The program knows how to
compensate for the fact that Windows
95 and Windows NT
_splitpath
parse differently.
GetDriveType("C:")
returns DRIVE_FIXED on NT 4.0 and
DRIVE_NO_ROOT_DIR on Win95.
GetDriveType("C:\")
returns DRIVE_FIXED on both systems.