Solved

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

Posted on 2013-12-29
2
980 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Suggested Solutions

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

820 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