Kzw
Kzw

Reputation: 23

WinApi FindFirstFile and the file handle

I got some problem with using FindFirstFile/FindNextFile. As I know it returns a handle but I'm not capable to use it with CreateFileMapping/ReadFile because value of returned handle is different than returned from CreateFile. First question: What's the difference between these two handles and the second: is it possible to convert this handle? My only idea is to get the file name and than use CreateFile.

Regards

Upvotes: 1

Views: 1358

Answers (1)

Soonts
Soonts

Reputation: 21936

What's the difference between these two handles

The first one is search handle. Underneath, there's an iterator reading the directory entry in the file system. The second one is an iterator reading the file content. The file may even be on another volume than the directory entry you've used to locate it. To learn more about that, google "B-Tree" and then "NTFS"

get the file name and than use CreateFile

Yes, but you need to combine directory + file name. I usually call PathAppend API (CPathT::Append, to be precise) to do that.

Upvotes: 2

Related Questions