Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2013-12-29
2
Medium Priority
?
1,065 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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
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.

877 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