If you wanted a volume handle (for use with I/O control codes) you would have needed to drop the trailing slash.
In order to get a handle to the root directory, you need to keep the trailing slash and pass the FILE_FLAG_BACKUP_SEMANTICS
flag in the dwFlagsAndAttributes
argument. This is documented on the MSDN page under the heading "Directories". For example, this is what you want to do if you're planning to call GetFileInformationByHandle
or GetFileInformationByHandleEx
.
Ordinarily, however, you wouldn't open a handle to the root directory in order to list the files. Instead, you would use FindFirstFile
/FindNextFile
or one of the related functions.