Do Not Mix Operating System and CRT File Handles (139640)
The information in this article applies to:
- Microsoft Visual C++ 2.0
- Microsoft Visual C++ 2.1
- Microsoft Visual C++ 2.2
- Microsoft Visual C++ 4.0
- Microsoft Visual C++, 32-bit Enterprise Edition 5.0
- Microsoft Visual C++, 32-bit Enterprise Edition 6.0
- Microsoft Visual C++, 32-bit Professional Edition 5.0
- Microsoft Visual C++, 32-bit Professional Edition 6.0
- Microsoft Visual C++, 32-bit Learning Edition 6.0
This article was previously published under Q139640 SUMMARY
In 32-bit Windows-based applications, Windows API functions (OpenFile,
CreateFile, and so on) return a file handle that cannot be substituted for
a handle returned by a C Runtime Function (_open, _wopen, and so on). You
can convert an operating system handle to a CRT handle by using the CRT
function _open_osfhandle() as demonstrated in the "Sample Code" section of
this article.
NOTE: This distinction is not Win32 specific. However, some programmers
using 16-bit products on 16-bit operating systems have mixed operating
system and CRT file handles.
Modification Type: | Major | Last Reviewed: | 12/1/2003 |
---|
Keywords: | kbcode kbCRT kbinfo KB139640 |
---|
|