Solved

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

Posted on 2013-12-29
2
1,011 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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 learn how to clear a vector as well as how to detect empty vectors in C++.

630 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