Solved

[C++] How do I know FILE_FLAG_OVERLAPPED has been set in the file handle ?

Posted on 2013-12-29
2
946 Views
Last Modified: 2013-12-30
Hello Experts,

I want to know FILE_FLAG_OVERLAPPED flag has been set in the file handle.

I got a file handle from DuplicateHandle() and that is HANDLE_TYPE_FILE and
my target file name.
I want to read that file by using duplicated handle, but I don't know
FILE_FLAG_OVERLAPPED flag has been set or not into that file handle.

If I know that flag information, I can call ReadFile() with/without OVERLAPPED
structure pointer.

Any hints welcome.

Windows 7 32bit
C++Builder

Nobuo Miwa
0
Comment
Question by:NobMiwa
2 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 39747239
>>I want to read that file by using duplicated handle, but I don't know
>>FILE_FLAG_OVERLAPPED flag has been set or not into that file handle.

>>If I know that flag information, I can call ReadFile() with/without OVERLAPPED
>>structure pointer.

It's actually quite easy: Even though there is no documented means to find out if that flag has been set, you can deal with this in both ways

- just don't pass an OVERLAPPED pointer, use NULL instead. The operation will be carried out synchronously (setting that flag does not mean you have to use the HANDLE in any async calls)

- pass an OVERLAPPED pointer anyway. If the flag was not set, the operation will be carried out synchronously. If it was set, use the means of async I/O.

A little more here: http://blogs.msdn.com/b/oldnewthing/archive/2012/04/05/10290954.aspx ("You can use an OVERLAPPED structure with synchronous I/O, too")
0
 

Author Closing Comment

by:NobMiwa
ID: 39747343
Great thanks !
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now